I am trying to use D3js Time to parse this timestamp
11-01-2017 1:48:00 PM
I have typed
var parseDate = d3.timeParse("%d-%m-%Y %H:%M:%S");
but it is not working.
答案 0 :(得分:6)
由于您的字符串以PM
结尾,因此您在说明符末尾缺少%p
。根据{{3}}:
%p - AM或PM。
以下是演示:
var date = "11-01-2017 1:48:00 PM";
var parseDate = d3.timeParse("%d-%m-%Y %H:%M:%S %p");
console.log(parseDate(date))
<script src="https://d3js.org/d3.v4.js"></script>