Version :"khill/lavacharts": "3.1.*",
Controller provides carbon date object and datatable is completed as per below ;
In PHP code
$dataTable = \Lava::DataTable();
$formatter = \Lava::DateFormat([
'pattern' => 'MMM d, HH:mm',
//'timeZone' => '', //same results without timezone parameter or with 'timeZone' => 2,
]);
$DataTable->addDateColumn('closing hour', $formatter)
->addNumberColumn('closing price')
->addNumberColumn('product evaluation')
->setDateTimeFormat('Y-m-d H:i:s')
->setTimezone('UTC') ; //added but no effect
for (...){
//$hour_start-->toIso8601String() == 2018-09-07T17:00:00+00:00 6430.4420188271
$dataTable->addRow([$hour_start->toDateTimeString(), $hourly_closing_price ,$hourly_value]);
}
**return $dataTable->toJson();//added after answer of WhiteHat**
Log::info(' dataTable '.$dataTable->toJson());
However while logged php json of datatable is as per below, for each row :
{"c":[{"v":"Date(2018,8,7,17,0,0)"},{"v":6430.442018827109}...
In javascript after ajax call to my Laravel controller, received json is a per below
{"c":[{"v":"2018-09-07T15:00:00.000Z","f":"Sep 7, 17:00"},{"v":6430.442018827109},{"v":0}]} .
There a 2 hour difference between f column (my UTC date) and v column (my UTC date minus 2h).
I changed my browser local time zone for test but no effect. Data provided are in UTC, server is in UTC and timezone set on chart is UTC but somewhere in google chart, a 2h difference is applied.
It seems google server doesnt consider the dates sent as UTC time and change the v value while keeping the f formatted value
With
$formatter = \Lava::DateFormat([
'pattern' => 'MMM d, HH:mm',
'timeZone' => 0,
]);
=> f and v column on same timezone but changed as if input date was not UTC (but UTC+2)
{"c":[{"v":"2018-09-07T15:00:00.000Z","f":"Sep 7, 15:00"},{"v":6430.442018827109},{"v":0}]}
Any clue someone?