广树
2024-11-22 20:09
@阿猫:原来如此😀
作者:广树时间:2018-03-06 16:16:10分类:JavaScript/jQuery/Vue
经常用到备份下,方便复制。
filters: { capitalize: function (value) { var date = new Date(parseInt(value)); var tt = [date.getFullYear(), date.getMonth()+1, date.getDate()].join('-') + ' ' +[date.getHours(), date.getMinutes(), date.getSeconds()].join(':'); return tt; } }例:
{{time | capitalize}} => 2018-3-6 15:52:43
新增时间补充0的方法
filters: { capitalize: function (value) { var date = new Date(parseInt(value)); var tt = [date.getFullYear(), ((date.getMonth()+1)<10?'0'+(date.getMonth()+1):date.getMonth()+1), (date.getDate()<10?'0'+date.getDate():date.getDate())].join('-') + ' ' +[(date.getHours()<10?'0'+date.getHours():date.getHours()), (date.getMinutes()<10?'0'+date.getMinutes():date.getMinutes()), (date.getSeconds()<10?'0'+date.getSeconds():date.getSeconds())].join(':'); return tt; } }
{{time | capitalize}} => 2018-03-06 15:02:03