【发布时间】:2019-04-04 23:50:04
【问题描述】:
我从我的 API 获得两个单独的时间和日期值。
date: 20190404
time: 09:30
我想将两者组合成一种可接受的格式,例如 YYYY-MM-DDThh:mm:ss。
我尝试了以下方法:
moment(data[i].date + 'T' + data[i].time).valueOf()
但我在控制台中收到以下错误:
Deprecation 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. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.
我的数组中的值显示为“NaN”
谢谢!
【问题讨论】:
-
手动指定格式,按momentjs.com/docs/#/parsing/string-format看
moment(..)和moment.utc(..)的区别momentjs.com/docs/#/parsing的顶部注意了
标签: momentjs