标签:
var nowTime = null;
//获取服务器时间
function GetTime() {
$.ajax({
url:config._domain + "/AjaxAuctionCenter/GetDbTime",
data: {},
type: "POST",
async:false,
success: function (data) {
if (data != null) {
nowTime = data;
}
}
});
}
$(function() {
/*设置日期时间*/
GetTime();
setInterval(setDate, 30000);
var myDate = new Date(Date.parse(nowTime.replace(/-/g, "/")));
setDate();
function setDate() {
var myYear, myMonth, myDay, myHours, myMinutes;
myYear = myDate.getFullYear();
myMonth = myDate.getMonth() + 1;
myDay = myDate.getDay();
myHours = myDate.getHours();
myMinutes = myDate.getMinutes();
//console.log(myDay)
//myDate = myDate.getDate();
$(‘#my_year‘).html(myYear);
$(‘#my_month‘).html(toDuble(myMonth));
$(‘#my_day‘).html(toDuble(myDate.getDate()));
$(‘#my_hours‘).html(toDuble(myHours));
$(‘#my_minutes‘).html(toDuble(myMinutes));
$(‘#my_week‘).html(myDay);
try {
switch (myDay) {
case 1:
$(‘#my_week‘).html("一");
break;
case 2:
$(‘#my_week‘).html("二");
break;
case 3:
$(‘#my_week‘).html("三");
break;
case 4:
$(‘#my_week‘).html("四");
break;
case 5:
$(‘#my_week‘).html("五");
break;
case 6:
$(‘#my_week‘).html("六");
break;
case 0:
$(‘#my_week‘).html("日");
break;
default:
}
} catch (e) {
}
myDate.setTime(myDate.getTime() + 30000);
}
function toDuble(num) {
if (num < 10) {
return ‘0‘ + num;
} else {
return ‘‘ + num;
}
}
});
标签:
原文地址:http://www.cnblogs.com/phone15138028025/p/4575251.html