I am using React Native
to develop a mobile application.
I am getting from the backend a timestamp
that I need to convert to a specific date format for Germany Munich
timezone and I need to take care of the added hours in winter and summer.
Here is how my code is working right now
unixTime(unixtime) {
var u = new Date(unixtime * 1000);
return ('0' + u.getUTCDate()).slice(-2) +
'.' + ('0' + (u.getUTCMonth() + 1)).slice(-2) +
'.' + u.getUTCFullYear() +
' ' + ('0' + u.getUTCHours()).slice(-2) +
':' + ('0' + u.getUTCMinutes()).slice(-2) +
':' + ('0' + u.getUTCSeconds()).slice(-2)
},
How can I achieve that?
Update: Here is what I've found, can someone validate if it is correct?
u = u.toLocaleString("en-US", {timeZone: "Europe/Berlin"})