function numberDoubled(n){
n = n+"";
return n.length==1?"0"+n:n;
}
function date2string(d, sp){
sp = sp || "-";
var year = d.getFullYear();
var month = d.getMonth()+1;
var date = d.getDate();
var hour = d.getHours();
var min = d.getMinutes();
var sec = d.getSeconds();
return year + sp + numberDoubled(month) + sp + date + " " + numberDoubled(hour) + ":" + numberDoubled(min) + ":" + numberDoubled(sec);
}
原文地址:https://www.cnblogs.com/sunyang-001/p/10812817.html
时间: 2024-10-09 18:58:54