ngx-moment
ngx-moment copied to clipboard
Timezone support in the future?
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.
Hi,
How do you set it up for the timezone with angular1 ?
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
@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?
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.
Same problem here, and now, after updating moment, I can't even set the global locale, that sucks
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 you may want to contribute this pipe in a PR so everyone can enjoy it
@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);
}
});
can we override to moment-timezone
instead of moment
?
Related: moment/moment-timezone#385
@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
@mj1856 When this issue will be fixed? --> Related: moment/moment-timezone#385
Up
In the meantime you can set the default with: moment.tz.setDefault(timezone);
Is there any way to use timezone in Angular 2 with pipes? Help me!!!
Can we have some information here ? I can't set the timezone manually.. it will not work in pipes.
Hi! Any new about this feature? How can we tell the amTimeAgo pipe to convert the date to client timezone?
@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);
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
In the meantime you can set the default with:
moment.tz.setDefault(timezone);
where in angular is the most appropriate place to set this
+1