美文网首页
时间戳、日期格式转化

时间戳、日期格式转化

作者: 砚婉儿 | 来源:发表于2019-12-19 11:32 被阅读0次

时间戳转日期:

let time = 1576725414;   // 先定义一个时间戳

12小时制:

new Date(parseInt(time) * 1000).toLocaleString().replace(/:\d{1,2}$/,' ')

24小时制:

new Date(parseInt(time) * 1000).toLocaleString('chinese',{hour12:false})

相关文章

网友评论

      本文标题:时间戳、日期格式转化

      本文链接:https://www.haomeiwen.com/subject/qwrmnctx.html