I'm struggling now with a time problem.
I'm using the NVD3 library to create my chart, I calculate all the chart data at the server side.
The problem is that the time range at the graph is according to my computer time (GMT+3) and not my machine (UTC). How can I fetch it to be UTC and not GMT+3?
What can I do?
I'm adding my code if it can help
nv.addGraph(function() {
var chart = nv.models.lineWithFocusChart().x(function(d) {return d[0];}).y(function(d) { return d[1]; });
chart.yAxis
.tickFormat(d3.format(',.2f'));
chart.y2Axis
.tickFormat(d3.format(',.2f'));
chart.xAxis
.tickFormat(function(d) { return d3.time.format('%H:%M:%Z')(new Date(d)) });
chart.x2Axis
.tickFormat(function(d) { return d3.time.format('%H:%M:%Z')(new Date(d)) });
d3.select('#chart svg')
.datum(data)
.transition().duration(500)
.call(chart);
return chart;
found a solution !
var now =new Date();
chart.xAxis.tickFormat(function(d) { if (d!= undefined)
{
return d3.time.format('%H:%M')(new Date(d+ now.getTimezoneOffset() * 60000 +Number(timeZoneOffset) )) }
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With