////發表時間(now) function p(s) { return s < 10 ? '0' + s : s; } var myDate = new Date(); //獲取當前年 var year = myDate.getFullYear(); //獲取當前月 var month = myD ...
////發表時間(now)
function p(s) {
return s < 10 ? '0' + s : s;
}
var myDate = new Date();
//獲取當前年
var year = myDate.getFullYear();
//獲取當前月
var month = myDate.getMonth() + 1;
//獲取當前日
var date = myDate.getDate();
var h = myDate.getHours(); //獲取當前小時數(0-23)
var m = myDate.getMinutes(); //獲取當前分鐘數(0-59)
var s = myDate.getSeconds();
var now = year + '-' + p(month) + "-" + p(date) + " " + p(h) + ':' + p(m) + ":" + p(s);