本文实例为大家分享了js获取当前时间的具体代码,供大家参考,具体内容如下
js获取当前时间
(昨天、今天、明天)开发过程中某些前台页面的时间控件我们需要给默认当前时间,jquery可以轻松的帮我们实现,代码如下
获取毫秒
var week;
month = month + 1;
if (month < 10) month = "0" + month;
if (date < 10) date = "0" + date;
if (hour < 10) hour = "0" + hour;
if (minu < 10) minu = "0" + minu;
if (sec < 10) sec = "0" + sec;
if (MS < 100)MS = "0" + MS;
var arr_week = new Array("星期日","星期一","星期二","星期三","星期四","星期五","星期六");
week = arr_week[day];
var time = "";
time = year + "年" + month + "月" + date + "日" + " " + hour + ":" + minu + ":" + sec + " " + week;
//当前日期赋值给当前日期输入框中(jQuery easyUI)
$("#currentDate").html(time);
//设置得到当前日期的函数的执行间隔时间,每1000毫秒刷新一次。
var timer = setTimeout("writeCurrentDate()",1000);
}
原文链接:https://www.f2er.com/js/44232.html