问题
highcharts gets my hour time wrong
I'm from venezuela just in case. I doing a real time system where I get in my db the time,seconds and miliseconds like 10:39:09:2
I apply the strtotime($time) then I sended by json to charted
and in my highcharts i got in the
xAxis: {
type: 'datetime',
title: {
text: 'Tiempo'
}
the utc function is already false
Highcharts.setOptions({
global: {
useUTC: false
}
});
and my function to get the json is
function requestData_Frecuencia() {
$.ajax({
url: 'Datos_Frecuencia.php',
success: function (point) {
var series = chart_Frecuencia.series[0],
shift = series.data.length > 400;
//add point
chart_Frecuencia.series[0].addPoint(eval(point), true, shift);
setTimeout(requestData_Frecuencia, 500);
},
cache: false
});
}
PS. is been a while since I write in english so forgive me if I write something wrong o that isn't clear.
回答1:
You should check the raw values in the database. I know that MySQL stores dates in GMT. Not sure about the DB you are using, but the reason that this is done is:
GMT is an absolute time reference & doesn't change with the seasons.
You will have to convert the time to your locale, which is UTC–04:30
Have a look at: Convert date to another timezone in JavaScript
回答2:
Highcharts doesn't include timezones and only what you can do is disabling UTC,aas you have. THen you need to translate your data or use label formatter / tooltip formatter to display correct data.
回答3:
I found out what I was doing wrong (found the answer here ). I used to get my time in php like:
while($r2 = pg_fetch_array($sth)) {
$hora = $r2['hora'];
$Frecuencia = $r2['frecuencia'];
}
$x=strtotime($hora);
I needed to multiplied by 1000 the time. I think, is because I need to suggested that date is in form of miliseconds (that is integer)
while($r2 = pg_fetch_array($sth)) {
$hora = $r2['hora'];
$Frecuencia = $r2['frecuencia'];
}
$x=strtotime($hora)*1000;
PD: thanks to everybody anyway for the suggestion and responses given. I really appreciated
来源:https://stackoverflow.com/questions/18339730/highcharts-gets-my-hour-time-wrong