Closed jxmot closed 3 years ago
Chosen Solution:
In mdcount.php
-
dtime
with time/date separators and use it for reports
The actual issue of the time being off was caused by how the time zone was being set. Although it did not cause any PHP errors or warnings the code was incorrect.
Correct Method:
$tm = $data->time = time();
$dt = new DateTime("@$tm");
$tz = new DateTimeZone(tzone());
$dt->setTimezone($tz);
$data->dtime = array($dt->format('Y-m-d'), $dt->format('H:i:s'));
Wrong Method:
$tm = $data->time = time();
$dt = new DateTime("@$tm", new DateTimeZone(tzone()));
$data->dtime = array($dt->format('Y-m-d'), $dt->format('H:i:s'));
According to the PHP manual setting the time zone in the contstructor is only valid with 'now'
in the first argument.
The date/time on shown in report.html is behind by 5 hours.
dtime
array is correcttime
data is correctBut when
time
is read from the counter and converted to strings then the time is behind by 5 hours.Possible Solution:
In
mdcount.php
-dtime
for time/date separators and use it for reportsElsewhere? -