简体   繁体   中英

How to convert a unix-timestamp to formatted date string in firebase

How do I convert a timestamp such as 1333699439 to 2008-07-17T09:24:17?

Currently in firebase, I'm using - timestamp: Firebase.ServerValue.TIMESTAMP.

the server return the timestamp in seconds So you need to multiple by thousand to get the time stamp in milisec like

var myDate = new Date(timestamp*1000);
var formatedTime=myDate.toJSON();

this formatedTime is your required format

您可以使用javascript Date对象执行此操作。

var myDate = new Date(timestamp_in_millis*1000);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM