I have input string like 2023-02-02 15:35 CET
and I have to convert this into UTC time.
I’m trying to find a solution for this, but I’m not able to figure out how to convert input string into Date() object in js.
My main problem is that I cannot figure out how to create Date() with timezone. Time-zones can differ and it could be anything like BST
, HKT
ect.
Can somebody help how to get UTC time from input string like this?
2
Answers
to convert your date to UTC you can use the
.toUTCString()
method.I just translated the PHP code from the following thread
https://stackoverflow.com/questions/67295211/convert-cest-cet-to-utc0
into javascript. Hope it will work for you