function getNowFormatDate() {
var date = new Date();
var month = date.getMonth() + 1;
var strDate = date.getDate();
var seperator1 = "-";
var seperator2 = ":";
var week = "星期" + "日一二三四五六".charAt(new Date().getDay()); //星期
//分秒时间是一位数字,在数字前补0。
function dataTwo (time){
if (time >= 1 && time <= 9) {
time = "0" + time;
}
return time;
}
var currentdate = date.getFullYear() + seperator1 + dataTwo(month) + seperator1 + dataTwo(strDate)+ " " + dataTwo(date.getHours()) + seperator2 + dataTwo(date.getMinutes())+ seperator2 + dataTwo(date.getSeconds());
return currentdate;
}
$("#Tim span").text(getNowFormatDate());
js获取系统时间,显示到页面上
最新推荐文章于 2022-10-22 08:06:49 发布