大家好,又见面了,我是你们的朋友全栈君。
- JS 时间戳转字符串:
var formatlistdate = function(time) {
var date=new Date(time);
var y = date.getFullYear();
var m = date.getMonth() 1;
var d = date.getDate();
var hour = date.getHours().toString();
var minutes = date.getMinutes().toString();
var seconds = date.getSeconds().toString();
if (hour < 10) {
hour = "0" hour;
}
if (minutes < 10) {
minutes = "0" minutes;
}
if (seconds < 10) {
seconds = "0" seconds;
}
return y '-' (m < 10 ? ('0' m) : m) '-' (d < 10 ? ('0' d) : d) " " hour ":" minutes ":" seconds;
}
- 字符串转时间戳
var newTime= Date.parse(new Date(time))
发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/142703.html原文链接:https://javaforall.cn