From the server I am getting a DateTime
in this format: 2019-07-11T05:33:53.45
and it is in UTC time.
I want to convert it to the current user’s browser time using JavaScript in the format like 11th July 2019 11:03 AM
which is UTC+0530
for Indian time for given time(2019-07-11T05:33:53.45).
I have tried Intl.DateTimeFormat
and also other JavaScript date time functions eg. toLocaleString
. But I am getting the time in UTC format only. When I get the time as what I want UTC+0530 is also attached, which I don't want.
let d = new Date(date_from_server);
let options= { year: 'numeric', month: 'numeric', day: 'numeric',
hour: 'numeric', minute: 'numeric', second: 'numeric',
hour12: false };
let ddmmmyy= new Intl.DateTimeFormat('default', options).format(d);
This is one of the solution I tried. I have tried other methods also, but didn't succeed. eg. let ddmmmyy = d.toLocaleString();
I want the time as per User's current browser timezone and in the specified format(11th July 2019 11:03 AM IST).
How can I achieve it? Please help.