'How to change a unix datetime into a different timezone unix datetime
I get datetime state like: "2022-05-18T18:30:00.000Z" - a moment datetime, then converts it to unix. But I do convert it in my local timezone, How do I change the timezone of the unix datetime and return in same unix format.
Timezone I get - Asia/Singapore
Code:
this.state.startTimeDate.unix() //This is how I convert it to unix format
How to change this unix to a different timezone ?
Solution 1:[1]
You could try converting the date to the client timezone before converting back to unix using moment like this ...
moment
.unix(1399335987)
.tz('MST')
.format('YYYY-MM-DDTHH:mm:ssZ');
And you get
"2022-05-20T17:01:27-07:00"
Before converting back to unix again. Hope this helps
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | awesome webber |
