To convert local time to UTC is easy:
var localTime = "2018-02-27 11:00";
moment(localTime).utc().format(); // result: "2018-02-27T09:00:00Z"
However I'm not sure if there is a straightforward way to convert my local time to CET (or other timezone such as EST, WEST)
I know that I can do something like this
moment(localTime).tz("Europe/Berlin").format();
which seems to return what I want but still unsure if thats the correct way or not?
You can use the moment-timezone
since it accounts for daylight saving.
moment(momentTZ().tz("Europe/Berlin")).format();
If you do not mind for daylight saving moment itself is fine.
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