I have a string 2021-04-07T13:51:39.664+11:00
which I use to create a Date
object: d = new Date('2021-04-07T13:51:39.664+03:00')
.
After that, d
is an instance to represent the date time. Now I'd like to get the timezone offset from d
, but d.getTimezoneOffset()
always return local timezone offset which is -600
in my case. How can I get the timezone offset from the string? Does it get lost when I build the date
instance? Do I have to parse the string to get it?
If I have a date
object, how can I generate a string with the offset at the end: 2021-04-07T13:51:39.664+03:00
? toISOString()
only generate UTC time.
I know moment
is a good date library but I don't want to add this dependency since it is too large.