我是靠谱客的博主 眼睛大牛排,这篇文章主要介绍转换时间格式的方法,现在分享给大家,希望可以做个参考。

 写一个转换时间格式的公用方法:

将'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

最后

以上就是眼睛大牛排最近收集整理的关于转换时间格式的方法的全部内容,更多相关转换时间格式内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部