js 时间格式处理
文章目录
new Date(new Date() + 8 * 3600 * 1000).toJSON().substr(0, 19).replace('T', ' ')
//"2019-12-19 09:04:52"
new Date(new Date() + 8 * 3600 * 1000).toJSON().substr(0, 10).replace('T', ' ')
//"2019-12-19"
/**
* 时间格式yyyy-MM-dd HH:mm:ss
*/
dateFormatter () {
const date = new Date();
const month = (date.getMonth() + 1).toString().padStart(2, '0');
const strDate = date.getDate().toString().padStart(2, '0');
this.form.updateTime = `${date.getFullYear()}-${month}-${strDate} ${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
}

评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论