javascript - momentjs 中的“无效日期”
问题描述
我有个约会:
let date = "15:00";
我想将其处理为 format: 2019-09-26T15:00:00.000Z
,但 momentjs 得到和无效日期错误。
我尝试使用moment(date).format('LTS');
解决方案
您还应该添加值的格式,如下所示:
let date = "15:00";
let m = moment(date, 'HH:mm').toISOString();
console.log(m);
因为你需要这样的东西2019-09-26T15:00:00.000Z
,所以最好使用toISOString
函数,而不是format
.
推荐阅读
- android - 是否可以更改 android 内置的 midi 播放器弯音范围?
- react-native - 如何在 rxjs 6 中订阅多个 observable?do 不是 rxjs 6 中的函数
- postgresql - PostgreSQL:只允许用户执行程序,但避免访问任何其他资源,例如表?
- azure - ASP.NET Core 身份、Azure SQL 数据库备份和 GDPR 数据删除请求
- c++ - 如何理解cout的默认格式
- assembly - 带有 YMM 寄存器的 AVX 中的 STRLEN 函数说明
- python - 学习熊猫数据框的预期输出
- python - 如何在网页 http://architects-register.org.uk/list/regions 中使用 Selenium 和 Python 点击按钮 A 到 Z
- infiniband - OFED、MLNX OFED 和收件箱驱动有什么区别
- javascript - 离子/角度发送短信到数组中的多个号码