首页 > 其他 > 详细

格式化时间

时间:2019-10-23 11:59:38      阅读:72      评论:0      收藏:0      [点我收藏+]
 1 <script>
 2     Date.prototype.Format = function (fmt) { //author: meizz
 3     var o = {
 4       "M+": this.getMonth() + 1, //月份
 5       "d+": this.getDate(), //
 6       "h+": this.getHours(), //小时
 7       "m+": this.getMinutes(), //
 8       "s+": this.getSeconds(), //
 9       "q+": Math.floor((this.getMonth() + 3) / 3), //季度
10       "S": this.getMilliseconds() //毫秒
11     };
12     if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
13     for (var k in o)
14       if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
15     return fmt;
16   }
17   var  submitTime = new Date().Format("yyyy-MM-dd hh:mm:ss")
18   console.log(submitTime);
19 </script>

 

格式化时间

原文:https://www.cnblogs.com/jspang/p/11725370.html

(1)
(1)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!