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

Anonymous said…
nice
for IT the said…
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai
ASO Services said…
There are so many useful information in your post, I like it all the time. And I want to share this boost app ranking with you, you can take a look. This is very useful.
ajay ak said…
Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
Webdesining course in chennai
Pretty blog, so many ideas in a single site, thanks for the informative article, keep updating more article.
hadoop training in chennai

angularjs training in chennai
Bhuvana Kandhan said…
Thanks a lot very much for the high quality and results-oriented help. I won’t think twice to endorse your blog post to anybody who wants and needs support about this area. We are providing AngularJS training in Velachery.

For more details: AngularJs training in velachery
Bhuvana Kandhan said…
Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here. we are providing AngularJs training in velachery.
for more details: AngularJs training in velachery
Good Post! Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging.

website builder for reseller
Thank you for the link building list.I am going jot down this because it will help me a lot.Great blog! Please keep on posting such blog.

private label website builder
Comfortabl y, the post is really the freshest on that deserving topic. I harmonise with your conclusions and definitely will thirstily look forward to your next updates. Simply saying thanks will not simply just be adequate, for the extraordinary clarity in your writing.

white label website builder

Popular posts from this blog

Measure the height of keyboard on PhoneGap app using jQuery

Step by step Cordova calabash-ios automation