蓝疆卫士,分奏网,黄千格
var now = new date(1539876689000).tolocalestring(); console.log(now);
后台传来时间戳,前台用js可以处理得到具体时间
2.正则表达式格式化时间
replace(/\/{1}/,'年') //将第一个出现的/替换成 年
.replace(/\/{1}/,'月') //将第二个出现的/替换成 月
.replace(/ {1}/,'日 ') //将第一个出现的空格替换成日+空格
.replace(/:\d{1,2}$/,' ')//将:后出现的连续一到两个数字到结尾(毫秒数)替换成空格
3.根据时间戳取时分秒,年月日
var now = new date(1539876689000); var day = now.getutcdate(); var year = now.getutcfullyear(); var month = now.getmonth(); var hour = now.getutchours(); var min = now.getminutes(); //console.log(year,month,day,hour,min); str = year + "年" + month +"月" + day +"日" +" " + hour +"时"+ min + "分"; console.log(str);
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
css3 flex布局 justify-content:space-between 最后一行左对齐
网友评论