Possible Duplicate:
Convert a Unix timestamp to time in Javascript
Turn a unix timestamp into 2008-07-17T09:24:17Z
How to do that?
You can simply use the fromtimestamp function from the DateTime module to get a date from a UNIX timestamp. This function takes the timestamp as input and returns the corresponding DateTime object to timestamp.
To convert a Firestore Timestamp into a Javascript date, just call . toDate() on the Timestamp. Save this answer.
The string format should be: YYYY-MM-DDTHH:mm:ss. sssZ , where: YYYY-MM-DD – is the date: year-month-day. The character "T" is used as the delimiter.
Unix time stamp is in seconds since epoch right? You can convert it into milliseconds (by multiplying it by 1000) and passing it to the date constructor like this to convert it to a Date object.
new Date(unixtimestamp*1000)
Then you can use the Date APIs to get parts of the date.
unix timestamp has an accuration of second, so convert to milisecond and pass to Date constructor:
var d = new Date(timestamp * 1000)
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