How to get local time from UTC using Moment.JS


Moment.JS is a beautiful javascript library for parsing, validating, manipulating, and formatting dates. This is a must have utility library when it comes to manipulating timestamps and dates in javascript.

Here I will show how to get local time if you have a utc date time string.

Lets say you have a UTC date-time string as 2014-02-19 05:24:32 AM and you want to determine time in your timezone then use following code:
 moment.utc('2014-02-19 05:24:32 AM').toDate();

toDate() method gives javascript Date() object.

Below I have shared an example of how to use it. You can click on JavaScript link below to see the code.

Comments

You have given essential data for us. about Analog And Mixed Signal Training Institutes It is excellent and good for everyone. Keep posting always. I am very thankful to you.
circuitengineer said…
I liked your work and, as a result, the manner you presented this content about PCB Board Cloning Service.It is a valuable paper for us. Thank you for sharing this blog with us.z
Anonymous said…
You've written a very detailed post regarding..... This information is useful to me and is also beneficial to people who...... I appreciate you providing this information.digital signature

Popular posts from this blog

Partially rendering Handlerbars from Backbone view

6 steps to create local copy of your live WordPress site