- mongodb - 在 MongoDB mapreduce 中,如何展平值对象?
- javascript - 对象传播与 Object.assign
- html - 输入类型 ="submit"Vs 按钮标签它们可以互换吗?
- sql - 使用 MongoDB 而不是 MS SQL Server 的优缺点
此文档提到 moment.ISO_8601
作为格式化选项(从 2.7.0 - http://momentjs.com/docs/#/parsing/special-formats/ ),但这些都不起作用(甚至 2.7.0):
var date = moment();
date.format(moment.ISO_8601); // error
moment.format(date, moment.ISO_8601); // error
( http://jsfiddle.net/b3d6uy05/1/ )
如何从 moment.js 获取 ISO 8601?
最佳答案
moment().toISOString(); // or format() - see below
http://momentjs.com/docs/#/displaying/as-iso-string/
更新根据答案:@sennet 和@dvlsg 的评论(参见 Fiddle)应该注意 format
和 toISOString
之间存在差异。两者都是正确的,但基本过程不同。 toISOString
转换为 Date 对象,设置为 UTC,然后使用 native Date 原型(prototype)函数以毫秒为单位输出 UTC 格式的 ISO8601 (YYYY-MM-DD[T]HH:mm:ss.SSS [Z]
)。另一方面,format
使用没有毫秒的默认格式(YYYY-MM-DDTHH:mm:ssZ
)并保持时区偏移。
我打开了 issue因为我认为这会导致意想不到的结果。
关于javascript - 如何在 moment.js 中将日期格式化为 ISO 8601?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25725019/
出于好奇,我尝试了一些原型(prototype)制作,但似乎只允许在第一个位置使用子例程的原型(prototype) &。 当我写作时 sub test (&$$) { do_somethin
我需要开发一个类似于 Android Play 商店应用程序或类似 this app 的应用程序.我阅读了很多教程,发现几乎每个教程都有与 this one 类似的例子。 . 我已经开始使用我的应用程
考虑一个表示“事件之间的时间”的列: (5, 40, 3, 6, 0, 9, 0, 4, 5, 18, 2, 4, 3, 2) 我想将这些分组到 30 个桶中,但桶会重置。期望的结果: (0, 1,
我是一名优秀的程序员,十分优秀!