better timezone handling

This commit is contained in:
Roland Gruber 2015-08-23 08:18:30 +00:00
parent db7ae2ea34
commit d9824cda40
1 changed files with 7 additions and 1 deletions

View File

@ -227,7 +227,13 @@ function logNewMessage($level, $message) {
if (is_writable($cfg->logDestination)) { if (is_writable($cfg->logDestination)) {
$file = fopen($cfg->logDestination, 'a'); $file = fopen($cfg->logDestination, 'a');
if ($file) { if ($file) {
fwrite($file, date('Y-m-d H:i:s') . ': ' . $message . "\n"); $timeZone = 'UTC';
$sysTimeZone = @date_default_timezone_get();
if (!empty($sysTimeZone)) {
$timeZone = $sysTimeZone;
}
$time = new DateTime(null, new DateTimeZone($timeZone));
fwrite($file, $time->format('Y-m-d H:i:s') . ': ' . $message . "\n");
fclose($file); fclose($file);
} }
} }