[DBW]格式化时间

[DBW]格式化时间,第1张

[DBW]格式化时间
Date.prototype.format = function(format) { //author: meizz
let o = {
"M+": this.getMonth() + , //月份
"d+": this.getDate(), //日
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + ) / ), //季度
"f+": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(format))
format = format.replace(RegExp.$, (this.getFullYear() + "").substr( - RegExp.$.length));
for (let k in o)
if (new RegExp("(" + k + ")").test(format))
format = format.replace(RegExp.$, (RegExp.$.length == ) ? (o[k]) : (("" + o[k]).substr(("" + o[k]).length)));
return format;
};
var d=new Date();
d.format('yyyy/MM/dd HH:mm');
//"2016/11/25 10:01"

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/588825.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-04-12
下一篇 2022-04-12

发表评论

登录后才能评论

评论列表(0条)

保存