Date.prototype.toLocaleString = function () {//改造Date.prototype.toLocaleString成为24小时制
return (
this.getFullYear() +
"年" +
(this.getMonth() + 1) +
"月" +
this.getDate() +
"日 " +
this.getHours() +
"点" +
this.getMinutes() +
"分" +
this.getSeconds() +
"秒"
);
};
//获取当前时间戳
let unixTimestamp = new Date(new Date().getTime());
//转换为24小时标准时间
let commonTime = unixTimestamp.toLocaleString();
alert(commonTime);
JS获取当前时间戳并转换为日期(24小时)
最新推荐文章于 2023-08-03 10:47:22 发布