kenshin9 kenshin9 - 1 year ago 151
PHP Question

Laravel 5.1 Logger Timezone

Is there a way I can change the timezone for the Laravel 5.1 logger? I've seen previous discussions where they extended the Monolog class and updated the Service Provider, but that was for an older version of Laravel and it doesn't look like the

is used anymore.

I see there's a
key in the
file, but I don't want the whole system to change. I just want to update the timezone for the logs, and keep the rest of the system in UTC.

Answer Source

I just saw your reply, I've figured it out and it's really simple. Create a new service provider and register it in config/app.php then add the following line to the boot method.

Logger::setTimezone(new \DateTimeZone('PST'));

Make sure you include the Logger class at the top of your service provider.

You may set the timezone to whichever one you'd like from this list,

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download