function getTime() {
var date = new Date()
var thisYear = date.getFullYear();
var thisMonth = date.getMonth() + 1;
//如果月份长度是一位则前面补0
if (thisMonth < 10) thisMonth = "0" + thisMonth;
var thisDay = date.getDate();
//如果天的长度是一位则前面补0
if (thisDay < 10) thisDay = "0" + thisDay;
var thisHour = date.getHours();
//如果小时长度是一位则前面补0
if (thisHour < 10) thisHour = "0" + thisHour;
var thisMinute = date.getMinutes();
//如果分钟长度是一位则前面补0
if (thisMinute < 10) thisMinute = "0" + thisMinute;
var thisSecond = date.getSeconds();
//如果分钟长度是一位则前面补0
if (thisSecond < 10) thisSecond = "0" + thisSecond;
return thisYear + "-" + thisMonth + "-" + thisDay + " " + thisHour + ":" + thisMinute + ":" + thisSecond;
}
获取当前系统时间、格式化日期时间
最新推荐文章于 2023-08-28 15:57:55 发布