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
Mapishere said…
In addition to its mapping and navigation features, https://mapishere.com/ also allows users to create and share custom maps. Whether you want to plan a route for a road trip or create a guide to your favorite local haunts, Mapishere.com makes it easy to share your maps with friends and family. And with its user-contributed database, the website is constantly growing and evolving, making it an invaluable resource for anyone looking to explore the world around them.
This way you can get a lot of information. Keep researching and reviewing.

Popular posts from this blog

Measure the height of keyboard on PhoneGap app using jQuery

6 steps to create local copy of your live WordPress site