0

我使用这个演示作为模板:http ://almende.github.io/chap-links-library/js/timeline/examples/example05_format_custom_html.html

这是一个很棒的时间线,但即使在官方示例中,源代码也会显示 7 月的日期,例如 new Date(2010, 7, 19) 并且时间线会显示一个月后的八月?我将 php 日期回显到 Date() 中,我遇到了同样的问题。我认为这可能是因为数组从 00 开始,但这个例子至少不是正确的吗?只是想知道是否有比从我所有的月份中减去 1 更简单的解决方法。谢谢你的帮助!!

小号

4

1 回答 1

4

JavaScript 月份为 0 索引。

结果,一月是 0,二月是 1,依此类推。因此,当您将其与您的数据匹配时,一切似乎都是一个月的时间。

new Date("2013-01-05").getUTCMonth(); // 0
new Date("2013-02-05").getUTCMonth(); // 1
new Date("2013-12-05").getUTCMonth(); // 11
于 2013-11-26T21:19:10.437 回答