adopted-ember-addons / ember-moment

MIT License
399 stars 122 forks source link

How to handle timezone issue with moment-from-now? #244

Closed hoIIer closed 7 years ago

hoIIer commented 7 years ago

Hello,

I have a time that is ahead a few hours in timezone that is being displayed improperly, how could I resolve this?

Example: The time should be displayed as "a few seconds ago" but instead it is "in 3 hours"

moment: {
  includeTimezone: 'all'
},

I added that per the docs but no effect,

thanks!

jasonmit commented 7 years ago

Are you setting the timeZone globally or passing it in as an attribute?

https://github.com/stefanpenner/ember-moment#configure-default-runtime-localetimezone

mitchiru commented 7 years ago

I have got a similar issue. I have a server date which is represented in UTC "Tue Jun 20 2017 08:02:35 GMT+0200" but my local time is +2. Ember moment still shows UTC.

My setup:

package.json: "ember-moment": "^7.3.1"

env~.js moment: { includeLocales: ['de'], includeTimezone: 'all' },

application router: moment: Ember.inject.service(), beforeModel() { this.get('moment').setTimeZone('Europe/Berlin'); //with or without, same result }

in my template: {{moment-from-now regionRolesChange.created_at hideSuffix=false}} --OUTPUTS UTC

{{regionRolesChange.created_at}} -- OUTPUTS "Tue Jun 20 2017 08:02:35 GMT+0200"

mitchiru commented 7 years ago

I got it running with this transform https://github.com/thoughtbot/ember-utc-transform

jasonmit commented 7 years ago

If anyone can replicate the issue and push an example somewhere please do and reopen.