程序员零花钱码上赚
//获取当前日期 2020-01-05 17:01:30
function getDate() {
var timezone = 8;
var offset_GMT = new Date().getTimezoneOffset();
var nowDate = new Date().getTime();
var today = new Date(nowDate + offset_GMT * 60 * 1000 + timezone * 60 * 60 * 1000);
var date = today.getFullYear() + "-" + twoDigits(today.getMonth() + 1) + "-" + twoDigits(today.getDate());
var time = twoDigits(today.getHours()) + ":" + twoDigits(today.getMinutes()) + ":" + twoDigits(today.getSeconds());
return date + ' ' + time
}
function twoDigits(val) {
if (val < 10) return "0" + val;
return val;
}