Reputation: 7318
I am working with HighStock Charts.
In the DB I have UTC DateTime '2015-04-21 11:09:21.000
':
I am cnverting this to Custom Time Zone in my Code (Should + 5 Hours in this Case):
TimeZoneInfo.ConvertTimeFromUtc(reading.dtUTCDateTime, assetCountryTimeZone);
As you can see below the Time in the View is correct: ie.
11:09 + 5 Hrs = 16:09
I then Convert the Array/List in Json:
<script type="text/javascript">
var avgCustomArray2 = @Html.Raw(Json.Encode(avgCustomArray2));
// Display first
var re = /-?\d+/;
for (var i = 0; i < avgCustomArray2.length; i++) {
var m = re.exec(avgCustomArray2[i].date);
if (i == 0) {
console.log(new Date(parseInt(m[0])));
console.log(parseInt(m[0]));
}
// Removed Code from here:
}
</script>
And in the Console.log()
I get the correct DateTime: Tue Apr 21 2015 16:09:21 GMT+0100 (GMT Daylight Time)
and in milliseconds: 1429628961000
Still (16:09) http://jsfiddle.net/3wux78tL/
So when I plot the Graph, I get the wrong time it is (15:09): Which is 1 hour less than the correct value
This is the HighChart Code setup:
$("#container").highcharts("StockChart", {
chart: { zoomType: "x" },
rangeSelector: { enabled: false },
legend: { enabled: true },
yAxis: [
{
tickInterval: 0.5,
min: 0
}
],
xAxis: [
{
title: { text: "Time " },
type: 'datetime'
}
],
series: [
{
data: chartData,
tooltip: { valueDecimals: 2 }
}
]
});
Upvotes: 0
Views: 426
Reputation: 1080
Refer to this: Highcharts - time off by 1 hour
Attempt to do:
Highcharts.setOptions({
global: {
// timezoneOffset: +1,
useUTC: false
}
});
Upvotes: 1