admin管理员组文章数量:1356353
I've got a date format which looks like this: 2017-02-18T09:00:00+06:00
.
This is the format I'm trying to parse it with: d3.utcParse("%Y-%m-%dT%H:%M:%S+%Z");
, but it returns null
.
Any ideas? Thanks!
I've got a date format which looks like this: 2017-02-18T09:00:00+06:00
.
This is the format I'm trying to parse it with: d3.utcParse("%Y-%m-%dT%H:%M:%S+%Z");
, but it returns null
.
Any ideas? Thanks!
Share Improve this question asked Feb 20, 2017 at 8:42 hanserinohanserino 13011 bronze badges3 Answers
Reset to default 6Instead of
d3.utcParse("%Y-%m-%dT%H:%M:%S+%Z");//+ is not needed
It should have been
d3.utcParse("%Y-%m-%dT%H:%M:%S%Z")
working code here
Your parsing specifier is not correct. The +
in the timezone +06:00
is actually part of the timezone and must not be included in the specifier string.
var parser = d3.utcParse("%Y-%m-%dT%H:%M:%S%Z");
console.log(parser("2017-02-18T09:00:00+06:00"));
<script src="https://d3js/d3.v4.js"></script>
That looks like an ISO 8601 datetime string. Why not try isoParse
instead of utcParse
?
d3.isoParse('2017-02-18T09:00:00+06:00')
For me this returns:
2017-02-18T03:00:00.000Z
Which is a correctly timezone-adjusted UTC datetime.
本文标签: javascriptD3js utcParse() returns nullStack Overflow
版权声明:本文标题:javascript - D3.js utcParse() returns null - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743977215a2570927.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论