How to Convert UTC Date Time to Local Date Time in JS
There are two ways to represent date strings as UTC date time.
var date_string = '6/29/2011 4:52:48 PM UTC'; OR var date_string = '2011-06-29T16:52:48.000Z'
In both these cases, you just need to pass them into Date() constructor to obtain a date object as per local time zone.
var localDate = new Date(date_string);
Thereafter, if you want to display date as a string, use toLocaleString() function.
While working with UTC date time, make sure that UTC datetime string has either Z or UTC suffix. This will allow the strings to be parsed correctly. If they are not present in your date string, please add it, before you proceed further.
var date_string = "2011-06-29T16:52:48"; var localDateTime = new Date(datetime + 'Z');
In this short article, we have learnt how to convert UTC time to local date time.
How to Use Variable Number of Arguments in JS Function
How to Add 1 Day to Current Date
How to Change One Character in Python String
How to Permanently Add Directory to Python Path
How to Install Python Package Using .whl file