js将时间戳转成时间格式

let start_time = 1653007401082,
   date = new Date(+start_time),
   Y = date.getFullYear() + '-',
   M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-',
   D = date.getDate() + ' ',
   h = date.getHours() + ':',
   m = date.getMinutes() + ':',
   s = date.getSeconds()
  this.start_time = Y + M + D   // '2022-05-20'

二,时间格式转换成时间戳方法

let data = new Date().getTime()

 

posted @ 2022-05-20 08:49  IT小姐姐  阅读(402)  评论(0编辑  收藏  举报