我又一次遇到了d3的麻烦。
基本上,我需要把两个日期传递给一个函数:
这两种方式都必须采用YYYY-MM-DD格式。
到目前为止,我得到的是:
console.log(d.Date); //2014-05-01
console.log(d.date); //Thu May 01 2014 00:00:00 GMT+0100 (BST)
console.log(d3.time.day.offset(d.date, 3)); //Sun May 04 2014 00:00:00 GMT+0100 (BST) 因此,offset看起来很好,但我真的需要这两种不同格式的约会。
非常感谢您的帮助!
发布于 2014-06-23 14:15:28
d3可以为您设置如下日期的格式:
formatter = d3.time.format("%Y-%m-%d");
formatter(d3.time.day.offset(new Date, 3)); // Returns "2014-06-27" (and today is the 24th!)https://stackoverflow.com/questions/24368109
复制相似问题