作者:加QQ873759613 | 来源:互联网 | 2023-01-30 15:18
let date = 'YYYY-MM-DD';
FormatUtcDate(new Date( date + ' 00:00:00 '))
FormatLocaDate(new Date( date + ' UTC '))
function FormatUtcDate(obj)
{
var str = '';
str += obj.getUTCFullYear() + '-';
if ((obj.getUTCMonth() + 1) <10) {
str += '0' + (obj.getUTCMonth() + 1) + '-';
}else{
str += (obj.getUTCMonth() + 1) + '-';
}
if (obj.getUTCDate() <10) {
str += '0' + obj.getUTCDate();
} else {
str += obj.getUTCDate();
}
return str +' '+ obj.getUTCHours() +':'+ obj.getUTCMinutes() +':'+ obj.getUTCSeconds();
}
function FormatLocaDate(obj){
var str = '';
str += obj.getFullYear() + '-';
if ((obj.getMonth() + 1) <10) {
str += '0' + (obj.getMonth() + 1) + '-';
}else{
str += (obj.getMonth() + 1) + '-';
}
if (obj.getDate() <10) {
str += '0' + obj.getDate();
} else {
str += obj.getDate();
}
return str;
}