vue中利用js截取时间的年月日
例如: let time =‘2019-10-11 15:17:49’年月日:let ti = time.split(’ ');月日:var timearr = time.replace(" ", ":").replace(/\:/g, "-").split("-");var timestr = ""+ Number(timearr[1])+ "月" + t...
·
- 例如: let time =‘2019-10-11 15:17:49’
- 年月日:let ti = time.split(’ ');
- 年月日:
var timearr = time.replace(" ", ":").replace(/\:/g, "-").split("-");
var timestr = timearr[0]+"年"+ Number(timearr[1])+ "月" + timearr[2]+"日";
- 时、分:
var timearr = time.replace(" ", ":").replace(/\:/g, "-").split("-");
var timestr = ""+timearr[3]+ " :" + timearr[4]+" ";
完整时间截取的方法:
getPartTime(val){
//let ti = val.split(' ');
var timearr = val.replace(" ", ":").replace(/\:/g, "-").split("-");
var timestr = ""+ Number(timearr[1])+ "月" + timearr[2]+"日";
console.log(4444,val)
return timestr;
},
调用:
<div class="mui-media-body">
<div class="mui-media-body-header">
<span class="h-title">{{item.title}}</span>
<span class="h-date">{{getPartTime(item.createTime)}}</span>
</div>
<div class="mui-media-body-trail">
<p class='mui-ellipsis'>您有14条任务通知还未查看</p>
<span class="mui-badge mui-badge-danger">{{item.num}}</span>
</div>
</div>
更多推荐
已为社区贡献3条内容
所有评论(0)