Time is an illusion but TimeZones are not.

Timezone configuration and management on the browser has never been easy. Here is some insight from Rishi

Learning shall never stop..!!!

Recently I have been working on handling timezones on a client project. Front end is AngularJs 1.3 and backend api is Rails api.

It is a very common scenario. User chooses what timezone the data should be displayed in. Api saves and returns all the dates in UTC format.

There are also a lot many client side validations comparing saved time with local time (in all permutation and combinations possible).

Tools used:

  1. Javascript Date object:

    While working with timezones, it is always good to know that Javascript Date object is always in local time zone. There is no direct option to set the timezone. You can change time by adding/subtracting timezone offset.

  2. moment.js: moment is a javascript library which provides pretty options to format the moment date object which is not possible with javascript Date object.
  3. moment-timezone.js: This library allows you to convert moment time object in…

View original post 311 more words

Advertisements

About Gautam Rege

Rubyist, Entrepreneur and co-founder of Josh-Software - one of the leading Ruby development shops in India.
This entry was posted in General. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s