/**
* 獲取當前時間
*
* @return 返回時間類型 yyyy-MM-dd HH:mm:ss
*/
* 獲取當前時間
*
* @return 返回時間類型 yyyy-MM-dd HH:mm:ss
*/
function sysTime(){
var myDate = new Date();
var year = myDate.getFullYear();
var month = myDate.getMonth()+1;
var date = myDate.getDate();
var h = myDate.getHours();
var m = myDate.getMinutes();
var s = myDate.getSeconds();
var now = year + '-' + getMakeZero(month) + "-" + getMakeZero(date) + " " + getMakeZero(h) + ':' + getMakeZero(m) + ":" + getMakeZero(s);
return now;
}
/**
* 時間補0
*
* @return 返回時間類型 yyyy-MM-dd HH:mm:ss
*/
* 時間補0
*
* @return 返回時間類型 yyyy-MM-dd HH:mm:ss
*/
function getMakeZero(s) {
return s < 10 ? '0' + s : s;
}
小白一枚,勤於整理,多多指教。
轉載請注明來源,感謝合作。