//格式化当前日期
function formatDate() {
var time = new Date()
var myyear = time.getFullYear();
var mymonth = time.getMonth() + 1;
var myweekday = time.getDate();
var myhours = time.getHours()
var mygetMinutes = time.getMinutes()
var mygetSeconds = time.getSeconds()
if (mymonth < 10) {
mymonth = "0" + mymonth;
}
if (myweekday < 10) {
myweekday = "0" + myweekday;
}
if (myhours < 10) {
myhours = "0" + myhours;
}
if (mygetMinutes < 10) {
mygetMinutes = "0" + mygetMinutes;
}
if (mygetSeconds < 10) {
mygetSeconds = "0" + mygetSeconds;
}
return (myyear + "-" + mymonth + "-" + myweekday + " " + myhours + ":" + mygetMinutes + ":" + mygetSeconds);
}
js格式化当前时间 yyyy-mm-dd hh:mm:ss
最新推荐文章于 2024-04-22 17:24:26 发布
关键词由CSDN通过智能技术生成