moment 时间戳转时间报错的原因分析 yxl 2018-09-14 12:09:32 263文章目录 1、如果是报的错误是:eprecation warning: value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged and will be removed in an upcoming major release 01.查看你的时间戳是否正确 02.查看数据库保存的是否是对象格式或者是时间格式,如果是字符串格式就会报错,需要转对象 利用 let time = JSON.parse(时间) 转为对象格式在进行moment(time).format('YYYY-MM-DD HH:mm:ss') 2、moment常用时间戳和时间互换 var moment = require('moment') 获取时间戳 : var res = moment(Date.now(), 'YYYY-MM-DD HH:mm:ss').valueOf(); 获取格式时间: var res = moment(Date.now()).format('YYYY-MM-DD HH:mm:ss');Tags: moment您觉得不错,可以分享到:关于本站凡本站注明"本站"或"投稿"的所有文章,版权均属于本站或投稿人,未经本站授权不得转载、摘编或利用其它方式使用上述作品。关于作者__construct幸福不会遗漏为之付出的人 上一篇文章教你玩转ES6下一篇文章 js的跨域、存储和浏览器缓存