PeeHaa / OpCacheGUI

GUI for PHP's OpCache
1.46k stars 170 forks source link

Timezone setting does not seem to have an effect #63

Closed CommanderBond closed 6 years ago

CommanderBond commented 9 years ago

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?

PeeHaa commented 9 years ago

I think this is a bug. Will investigate.

ymchun commented 9 years ago

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');

CommanderBond commented 9 years ago

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

PeeHaa commented 9 years ago

Tnx @ymchun

will go through the code to fix it in a later release.

CommanderBond commented 9 years ago

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'),
blueJack92 commented 8 years ago

I have this bug, too. Please fix it! Thank you very much for this great OpCache-GUI!

PeeHaa commented 6 years ago

Fixed it master.

Sorry for letting you wait two years+ :-(

💓