700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > JS获取当前时间戳并转换为日期(24小时)

JS获取当前时间戳并转换为日期(24小时)

时间:2020-01-04 16:55:10

相关推荐

JS获取当前时间戳并转换为日期(24小时)

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);

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。