简体   繁体   English

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

[英]What is the correct format of a date for a Morris.js coffee file

I have the following .js.coffee file 我有以下.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']

What is the correct date format to display the months correctly? 什么是正确显示日期的正确日期格式?

None of these seem to work properly 这些似乎都无法正常工作

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

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

Quote from the official documentation 引用官方文件

Timestamps are accepted in the form of millisecond timestamps (as returned by Date.getTime() or as strings in the following formats: 时间戳以毫秒时间戳的形式(由Date.getTime()返回或以以下格式的字符串形式接受):

 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. 注意:使用毫秒时间戳时,建议您检出dateFormat选项。 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. 注意2:日期/时间字符串可以选择在日期和时间部分之间包含T,和/或Z后缀,以与ISO-8601日期兼容。

Just replace slashes by hyphens, and it should be ok 只需用连字符替换斜杠,就可以了

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM