1
0
mirror of https://github.com/Seldaek/monolog.git synced 2025-08-08 14:16:42 +02:00

#1539 fix timezone when it's DateTimeImmutable

This commit is contained in:
Yi Yang
2021-03-11 15:05:33 -08:00
committed by GitHub
parent c1971982c3
commit f6802992d2

View File

@@ -97,9 +97,12 @@ class SyslogUdpHandler extends AbstractSyslogHandler
} }
if ($this->rfc === self::RFC3164 && ($datetime instanceof \DateTimeImmutable || $datetime instanceof \DateTime)) { if ($this->rfc === self::RFC3164 && ($datetime instanceof \DateTimeImmutable || $datetime instanceof \DateTime)) {
$datetime->setTimezone(new \DateTimeZone('UTC')); $dateNew = $datetime->setTimezone(new \DateTimeZone('UTC'));
$date = $dateNew->format($this->dateFormats[$this->rfc]);
}
else {
$date = $datetime->format($this->dateFormats[$this->rfc]);
} }
$date = $datetime->format($this->dateFormats[$this->rfc]);
if ($this->rfc === self::RFC3164) { if ($this->rfc === self::RFC3164) {
return "<$priority>" . return "<$priority>" .