Git Product home page Git Product logo

Comments (21)

Yamilquery avatar Yamilquery commented on June 14, 2024 4

Is there any way to use timezone in Angular 2 with pipes?
Help me!!!

from ngx-moment.

basvdijk avatar basvdijk commented on June 14, 2024 2

I am also looking for a locale timezone supported feature. Currently when I use {{tdata.created | amTimeAgo}} it has a two hour offset from the current client timezone. I was wondering if I need to specify anything since the client timezone could be auto-detected.

from ngx-moment.

redmember avatar redmember commented on June 14, 2024 1

@mj1856 When this issue will be fixed?
--> Related: moment/moment-timezone#385

from ngx-moment.

morriq avatar morriq commented on June 14, 2024 1

@BenDevelopment just copy it to your project / or fork it on github.

It's easy to achieve. Just redefine this.lastText with:
this.lastText = moment.utc(value).local().from(moment(), omitSuffix);

from ngx-moment.

urish avatar urish commented on June 14, 2024

Hi,

How do you set it up for the timezone with angular1 ?

from ngx-moment.

grapemix avatar grapemix commented on June 14, 2024

I think the following post will explain better the solution than my word:

http://stackoverflow.com/questions/25283901/how-to-set-angular-moment-timezone-globally

from ngx-moment.

dragGH102 avatar dragGH102 commented on June 14, 2024

@urish I'm also interested. I noticed in your angular-moment package you actually give an explanation on how to use moment**'-timezone**: https://github.com/urish/angular-moment

Also, does moment actual support half / three-quarter time zones?

from ngx-moment.

marcoskichel avatar marcoskichel commented on June 14, 2024

Same problem here, and now, after updating moment, I can't even set the global locale, that sucks

from ngx-moment.

rdicroce avatar rdicroce commented on June 14, 2024

I found a workaround, if the date to be parsed contains timezone information. You can make a custom Angular pipe that just parses the string using moment.parseZone(), then add that pipe before amDateFormat (or whatever pipe you're using).

from ngx-moment.

urish avatar urish commented on June 14, 2024

@rdicroce you may want to contribute this pipe in a PR so everyone can enjoy it

from ngx-moment.

rdicroce avatar rdicroce commented on June 14, 2024

@urish I'm building my app using straight JavaScript rather than TypeScript. The pipe's really simple though, so you shouldn't have any problem porting it to TS:

var ngCore = require('@angular/core');
var moment = require('moment');

exports.MomentParseZonePipe = ngCore.Pipe({
    name: 'momentParseZone'
})
.Class({
    constructor: function () {},
    transform: function (value) {
        return moment.parseZone(value);
    }
});

from ngx-moment.

kodeine avatar kodeine commented on June 14, 2024

can we override to moment-timezone instead of moment?

from ngx-moment.

mattjohnsonpint avatar mattjohnsonpint commented on June 14, 2024

Related: moment/moment-timezone#385

from ngx-moment.

mattjohnsonpint avatar mattjohnsonpint commented on June 14, 2024

@dragGH102

Also, does moment actual support half / three-quarter time zones?

Yes, moment-timezone supports the entire IANA time zone database, including strange oddities like Asia/Nepal and Australia/Eucla

from ngx-moment.

morriq avatar morriq commented on June 14, 2024

Up

from ngx-moment.

cur3n4 avatar cur3n4 commented on June 14, 2024

In the meantime you can set the default with: moment.tz.setDefault(timezone);

from ngx-moment.

JoaoPintoM avatar JoaoPintoM commented on June 14, 2024

Can we have some information here ? I can't set the timezone manually.. it will not work in pipes.

from ngx-moment.

BenDevelopment avatar BenDevelopment commented on June 14, 2024

Hi!
Any new about this feature? How can we tell the amTimeAgo pipe to convert the date to client timezone?

from ngx-moment.

ryan-morris avatar ryan-morris commented on June 14, 2024

Any word on this? I have objects with full time/zone information 2017-12-12T16:12:00-05:00 but it gets changed to the browser time zone, I'd like to preserve the timezone from the input string when formatting, e.g shows 2017-12-12 17:12:00 when I use amDateFormat of YYYY-MM-DD HH:mm:ss in the html when on a browser set to -04:00 offset

from ngx-moment.

radiumrasheed avatar radiumrasheed commented on June 14, 2024

In the meantime you can set the default with: moment.tz.setDefault(timezone);

where in angular is the most appropriate place to set this

from ngx-moment.

maenthoven avatar maenthoven commented on June 14, 2024

+1

from ngx-moment.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.