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>