概述
写一个转换时间格式的公用方法:
将'2019-5-6 16:30:02’ 转换成 2019年05月06日 16时30分02秒
~function(pro){ pro.formatTime=function(template){ template=template || '{0}年{1}月{2}日 {3}时{4}分{5}秒'; var ary=this.match(/d+/g); template=template.replace(/{(d+)}/g,function (){ var n=arguments[1], val=ary[n] || '0'; val<10?val= '0'+val:null; return val; }); return template; } }(String.prototype) var str='2019-5-6 16:30:02; str.formatTime();//2019年05月06日 16时30分02秒
转载于:https://www.cnblogs.com/xinxinxiangrong7/p/11432220.html
最后
以上就是眼睛大牛排为你收集整理的转换时间格式的方法的全部内容,希望文章能够帮你解决转换时间格式的方法所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复