//datetime is the timestamp obtained var date = new Date(datetime);//If the timestamp is 10 digits, *1000 is required, and if the timestamp is 13 digits, it does not need to be multiplied by 1000 var year = date.getFullYear(), month = ("0" + (date.getMonth() + 1)).slice(-2), sdate = ("0" + date.getDate()).slice(-2), hour = ("0" + date.getHours()).slice(-2), minute = ("0" + date.getMinutes()).slice(-2), second = ("0" + date.getSeconds()).slice(-2); // splice var
…
The post js formatting timestamps first appeared on Lenix Blog .
This article is reprinted from https://blog.p2hp.com/archives/8736
This site is for inclusion only, and the copyright belongs to the original author.