ngx-moment icon indicating copy to clipboard operation
ngx-moment copied to clipboard

Timezone support in the future?

Open grapemix opened this issue 8 years ago • 21 comments

Thanks for the work of this lib.

Will timezone feature support in the future? Ideally, we can set timezone once instead of passing the timezone setting every time we used this lib.

Currently, if the input is "2016-05-23T00:39:23.610812Z" and the local time is 21:39, this lib does not show correctly because time zone feature has not been implemented. In Angular 1, everything is fine.

Thanks.

grapemix avatar May 23 '16 04:05 grapemix

Hi,

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

urish avatar May 23 '16 05:05 urish

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

grapemix avatar May 23 '16 20:05 grapemix

@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?

dragGH102 avatar May 24 '16 12:05 dragGH102

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.

basvdijk avatar Jun 21 '16 08:06 basvdijk

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

marcoskichel avatar Jul 06 '16 20:07 marcoskichel

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).

rdicroce avatar Jul 07 '16 17:07 rdicroce

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

urish avatar Jul 07 '16 17:07 urish

@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);
    }
});

rdicroce avatar Jul 07 '16 17:07 rdicroce

can we override to moment-timezone instead of moment?

kodeine avatar Jul 28 '16 04:07 kodeine

Related: moment/moment-timezone#385

mattjohnsonpint avatar Sep 21 '16 19:09 mattjohnsonpint

@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

mattjohnsonpint avatar Sep 21 '16 19:09 mattjohnsonpint

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

redmember avatar Sep 22 '16 05:09 redmember

Up

morriq avatar Dec 14 '16 18:12 morriq

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

cur3n4 avatar Jan 25 '17 02:01 cur3n4

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

Yamilquery avatar Mar 04 '17 02:03 Yamilquery

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

JoaoPintoM avatar Mar 16 '17 13:03 JoaoPintoM

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

BenDevelopment avatar Jul 09 '17 16:07 BenDevelopment

@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);

morriq avatar Jul 10 '17 08:07 morriq

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

ryan-morris avatar Dec 12 '17 22:12 ryan-morris

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

where in angular is the most appropriate place to set this

radiumrasheed avatar Jun 18 '19 01:06 radiumrasheed

+1

maenthoven avatar Jul 17 '19 16:07 maenthoven