获取客户端的时区并计算当前时间
function formatDate(strDate) {
var timeZone = (new Date().getTimezoneOffset()) * 60 * 1000;
var len = new Date(strDate).getTime();
var date2 = new Date(len - timeZone);
return date2.getFullYear() + "/" + (p(date2.getMonth() + 1)) + "/" + p(date2.getDate()) + ' ' + p(date2.getHours()) + ':' + p(date2.getMinutes()) + ':' + p(date2.getSeconds());
}
双位小于10前面补0
function p(s) {
return s < 10 ? '0' + s: s;
}
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!