我正在用函数解析日期
parseDate = d3.time.format("%m-%Y").parse;
如果我给出的日期格式是月和年,效果会很好。。但我想使运行时的格式"%m-%Y"是动态的。因为有时我需要格式为%d-%m-%Y。
那么,如何使这个parseDate函数获取参数日期和格式呢?我在json数据中有格式。根据该数据,我将选择give argument的解析函数给parseDate函数。
类似的东西
function parseDate(format, date) {
return d3.time.format(format).parse(date);
}