Files
iblog2/public/dist/js/dateFormat.js
2018-11-19 20:30:53 +08:00

1 line
626 B
JavaScript

"use strict";function getDateStr(t,e){var r={"M+":t.getMonth()+1,"d+":t.getDate(),"H+":t.getHours(),"m+":t.getMinutes(),"s+":t.getSeconds(),"q+":Math.floor((t.getMonth()+3)/3),S:t.getMilliseconds()};for(var n in/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(t.getFullYear()+"").substr(4-RegExp.$1.length))),r)new RegExp("("+n+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?r[n]:("00"+r[n]).substr((""+r[n]).length)));return e}Date.prototype.dateFormat=function(t){return getDateStr(this,t)},String.prototype.jsonDateFormat=function(t){return getDateStr(new Date(parseInt(this.replace("/Date(","").replace(")/",""),10)),t)};