So you need to display some datetimes in your new ember.js/angular/backbone UI and the times must be displayed for a timezone which is different from the logged on user.
Let us say we have an Event class in our rails application with the following attributes:
1 2 3 4 5 6 | |
Rails uses the timezone format: Eastern Time (US & Canada)
Javascript (and therefore the moment-timezone library) use the format: America/New_York
Rails can easily convert this for you and return the proper js format in your json:
1 2 3 4 5 6 7 8 | |
and with moment.js and moment-timezone
1 2 | |
You will want to ensure that all json is being rendered with UTC as the configured timezone in rails,
i.e. config.time_zone = 'UTC' in your application config and/or Time.zone = 'UTC' in your api controller.
See also