CoffeeEddy
 1 Date.prototype.format = function (format) {
 2     var date = {
 3         "M+": this.getMonth() + 1,
 4         "d+": this.getDate(),
 5         "h+": this.getHours(),
 6         "m+": this.getMinutes(),
 7         "s+": this.getSeconds(),
 8         "q+": Math.floor((this.getMonth() + 3) / 3),
 9         "S+": this.getMilliseconds()
10     };
11     if (/(y+)/i.test(format)) {
12         format = format.replace(RegExp.$1, (this.getFullYear() + \'\').substr(4 - RegExp.$1.length));
13     }
14     for (var k in date) {
15         if (new RegExp("(" + k + ")").test(format)) {
16             format = format.replace(RegExp.$1, RegExp.$1.length == 1
17                    ? date[k] : ("00" + date[k]).substr(("" + date[k]).length));
18         }
19     }
20     return format;
21 }

如何调用?

var myDatetime=new Date(parseInt(myDate.replace("/Date(", "").replace(")/", ""))).format(\'yyyy-MM-dd hh:mm:ss\') 

 

分类:

技术点:

相关文章:

  • 2022-12-23
  • 2021-10-13
  • 2022-01-01
  • 2022-01-01
  • 2021-11-27
  • 2022-01-01
  • 2021-12-22
猜你喜欢
  • 2021-11-27
  • 2021-11-27
  • 2021-11-27
  • 2021-11-27
相关资源
相似解决方案