I have a UTC date string, "2011-10-30T18:30:00Z", and I want to convert it to "2011-10-30 18:30". Can anyone give me some advice how to do this? I would appreciate for your time and consideration.
Thanks
Given an UTC date and the task is to convert UTC date time into local date-time using JavaScript toLocaleString() function. Syntax: var theDate = new Date(Date.parse('06/14/2020 4:41:48 PM UTC')) theDate.toLocaleString() JavaScript code:
How to Convert a String into a Date in JavaScript. The best format for string parsing is the date ISO format with the JavaScript Date object constructor. But strings are sometimes parsed as UTC and sometimes as local time, which is based on browser vendor and version. It is recommended is to store dates as UTC and make computations as UTC.
we are able to get CreationTime into a String variable but unable to convert to UTC. Any idea to convert this? Show activity on this post. In Javascript you can use this method to convert a date from a Date () object, but not from a IST string.
But strings are sometimes parsed as UTC and sometimes as local time, which is based on browser vendor and version. It is recommended is to store dates as UTC and make computations as UTC. To parse a date as UTC, you should append a Z: The "Z" is crucial to ensure that the string is interpreted as UTC, not as local time.
The easiest solution is to try the following:
var date = new Date("2011-10-30T18:30:00Z");
This will convert it into a normal Javascript date, at which point you can use whatever data operators you like.
str=str.replace(/T|\:\d\dZ/g,' ')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With