标签:func time 日期 datetime add atd ddd date() ==
formatDate: function (date) {
function addDateZero(num) {
return (num < 10 ? "0" + num : num);
}
var d = new Date(date);
var formatdatetime = d.getFullYear() + ‘-‘ + addDateZero(d.getMonth() + 1) + ‘-‘ + addDateZero(d.getDate());
return formatdatetime;
}
formatDate1: function (date) {
function addDateZero(num) {
return (num < 10 ? "0" + num : num);
}
var d = new Date(date);
var formatdatetime = d.getFullYear() + ‘.‘ + addDateZero(d.getMonth() + 1) + ‘.‘ + addDateZero(d.getDate()) + ‘ ‘
+ (d.getHours() <= 12 ? (d.getHours() == 0 ? addDateZero(d.getHours() + 12) : addDateZero(d.getHours())) : addDateZero(d.getHours() - 12))
+ ‘:‘ + addDateZero(d.getMinutes())
+ ‘:‘ + addDateZero(d.getSeconds()) + ‘ ‘
+ (d.getHours() < 12 ? ‘AM‘ : ‘PM‘);
return formatdatetime;
}
标签:func time 日期 datetime add atd ddd date() ==
原文地址:https://www.cnblogs.com/huangbinlooksgood/p/14201757.html