gpt4 book ai didi

javascript - Morris.js 咖啡文件日期的正确格式是什么

转载 作者:行者123 更新时间:2023-11-29 18:17:10 27 4
gpt4 key购买 nike

我有以下 .js.coffee 文件

jQuery ->
Morris.Line
element: 'averages_chart'
data: [{month: '2014 01 01', average: 6}, {month: '2014 02 01', average: 5}]
xkey: 'month'
ykeys: ['average']
labels: ['Average']

正确显示月份的正确日期格式是什么?

这些似乎都不能正常工作

month: '2014 01 01'
month: 2014/01/01
month: '2014/01/01'
month: 'Jan 2014'

这是一个 js bin 示例:http://jsbin.com/uqawig/441/embed?javascript,live

最佳答案

引自official documentation

Timestamps are accepted in the form of millisecond timestamps (as returned by Date.getTime() or as strings in the following formats:

2012
2012 Q1
2012 W1
2012-02
2012-02-24
2012-02-24 15:00
2012-02-24 15:00:00
2012-02-24 15:00:00.000

Note: when using millisecond timestamps, it's recommended that you check out the dateFormat option. Note 2: date/time strings can optionally contain a T between the date and time parts, and/or a Z suffix, for compatibility with ISO-8601 dates.

把斜杠换成连字符就可以了

关于javascript - Morris.js 咖啡文件日期的正确格式是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22142912/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com