d3 v4版本
1.将日期字符串转化为d3中的日期对象
//字符串例如“2018-05-09T20:46:20.040Z”
var dateParse = d3.timeParse("%Y-%m-%dT%H:%M:%S.%LZ");
var timeobj=dateParse(timestring);
2.将日期对象转化为字符串形式
var dateFormat =d3.timeFormat("%b-%Y");
var timestr=dateFormat(timeobject);
3.若将得到的日期对象直接进行运算,将会得到数值。
4.d3中format格式:
%a - abbreviated weekday name.
%A - full weekday name.
%b - abbreviated month name.
%B - full month name.
%c - date and time, as “%a %b %e %H:%M:%S %Y”.
%d - zero-padded day of the month as a decimal number [01,31].
%e - space-padded day of the month as a decimal number [ 1,31]; equivalent to%_d.
%H - hour (24-hour clock) as a decimal number [00,23].
%I - hour (12-hour clock) as a decimal number [01,12].
%j - day of the year as a decimal numbe