1.毫秒值转化为正常时间格式  最简单的方法

new Date(后台传来的毫秒值).toLocaleDateString()

【JS】 JS毫秒值转化为正常格式   或者正常格式转化为毫秒值

就是这个样子

2.毫秒值转化为自定义的时间格式

本页面重写一下  toLocaleString()方法

Date.prototype.toLocaleString = function() {
          return this.getFullYear() + "年" + (this.getMonth() + 1) + "月" + this.getDate() + "日 " + this.getHours() + "点" + this.getMinutes() + "分" + this.getSeconds() + "秒";
    };

 

3.正常的时间格式 转化为毫秒值

(new Date("2011/11/11 20:10:10")).getTime()

 

相关文章:

  • 2021-12-29
  • 2021-10-02
  • 2021-12-28
  • 2022-12-23
  • 2021-11-19
  • 2021-09-17
  • 2021-10-13
  • 2021-11-19
猜你喜欢
  • 2022-12-23
  • 2021-11-19
  • 2022-12-23
  • 2021-11-19
  • 2021-07-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案