GMTToStr(time){
// 将 GMT格式的时间字符串 格式化为正常时间字符串
let date = new Date(time)
let Str=date.getFullYear() + '/' +
(this.handleTimeStr(date.getMonth() + 1)) + '/' +
this.handleTimeStr(date.getDate()) + ' ' +
this.handleTimeStr(date.getHours()) + ':' +
this.handleTimeStr(date.getMinutes()) + ':' +
this.handleTimeStr(date.getSeconds())
return Str
},
handleTimeStr(tStr){
// 解决 10:2:2 出现各位数字格式化为 10:02:02
if (tStr < 10){
return '0'+ tStr
}else {
return tStr
}
},在这里插入代码片
js GMT时间转换为格式化字符串
猜你喜欢
转载自blog.csdn.net/weixin_41822224/article/details/107580705
今日推荐
周排行