Closed CommanderBond closed 6 years ago
I think this is a bug. Will investigate.
PHP will ignore timezone when giving an integer timestamp to DateTime object
http://php.net/manual/en/datetime.construct.php
my fix:
change: src/OpCacheGUI/Status.php
$lastRestartTime = (new \DateTime('@' . $stats['last_restart_time']))->format('H:i:s d-m-Y');
to
$lastRestartTime = (new \DateTime())->setTimestamp($stats['last_restart_time'])->format('H:i:s d-m-Y');
Indeed,
correct times are displayed after changing 'start_time' => (new \DateTime('@' . $stats['start_time']))->format('H:i:s d-m-Y'), to 'start_time' => (new \DateTime())->setTimestamp($stats['start_time'])->format('H:i:s d-m-Y'), in src/OpCacheGUI/OpCache/Status.php
In the same file I changed $lastRestartTime = (new \DateTime('@' . $stats['last_restart_time']))->format('H:i:s d-m-Y'); to $lastRestartTime = (new \DateTime())->setTimestamp($stats['last_restart_time'])->format('H:i:s d-m-Y'); as well to display correct timestamp for restarts, too.
Thanks ymchun
Tnx @ymchun
will go through the code to fix it in a later release.
Btw, timestamp calculation for files in cache is missing timezone calculation, too: In the same file from above I changed
$timestamp = (new \DateTime('@' . $script['timestamp']))->format('H:i:s d-m-Y');
to
$timestamp = (new \DateTime())->setTimestamp($script['timestamp'])->format('d.m.Y H:i:s');
and
'last_used_timestamp' => (new \DateTime('@' . $script['last_used_timestamp']))->format('H:i:s d-m-Y'),
to
'last_used_timestamp' => (new \DateTime())->setTimestamp($script['last_used_timestamp'])->format('d.m.Y H:i:s'),
I have this bug, too. Please fix it! Thank you very much for this great OpCache-GUI!
Fixed it master.
Sorry for letting you wait two years+ :-(
💓
Hi,
on my Windows server, OpCacheGUI's default timezone (that fits to mine) is not correctly displayed in the report. Report shows UTC times. I tried to set it to Europe/Vienna or Europe/London in init.production.php, but it does not have an effect (other configuration changes in ths file have an effect!).
I was previously using opcache.php by Rasmus Lerdorf that correctly shows time values based on UTC+2.
What's wrong here?