Laravel Tutorials

Learn how to manage timezones in your Laravel Apps

Published

In this video, Ben Holmen teaches us how to manage timezones in your Laravel apps. Some of the highlights include:

  • Store all dates and times in UTC
  • Define a default application Timezone
  • Use Carbon macros for conversions
  • Either automatically or manually, allow the user to select their timezone

Here are the code samples used in the video:

In Application Timezone Macro

Carbon::macro('inApplicationTimezone', function() {
return $this->tz(config('app.timezone_display'));
});

In User Timezone Macro

Carbon::macro('inUserTimezone', function() {
return $this->tz(auth()->user()?->timezone ?? config('app.timezone_display'));
});

Give it a watch and learn all about Timezones and how to easily manage them!

Eric L. Barnes photo

Eric is the creator of Laravel News and has been covering Laravel since 2012.

Sponsored

laravelcloud logo
Laravel Cloud

Easily create and manage your servers and deploy your Laravel applications in seconds.

Visit Laravel Cloud

The latest

View all →
Laravel AI SDK 1.0 Adds Classification and Tool Approvals image

Laravel AI SDK 1.0 Adds Classification and Tool Approvals

Read article
Tagged Memoized Cache and Model Refreshes in Laravel 13.33 image

Tagged Memoized Cache and Model Refreshes in Laravel 13.33

Read article
Laravel Live Denmark 2026 Talks Are Now on YouTube image

Laravel Live Denmark 2026 Talks Are Now on YouTube

Read article
Live Stream: Building a Social Network in PHP in 48 Hours image

Live Stream: Building a Social Network in PHP in 48 Hours

Read article
Health for Laravel: Kubernetes Probes and Prometheus Metrics image

Health for Laravel: Kubernetes Probes and Prometheus Metrics

Read article
Fast Excel 5.x Adds Streaming Imports and Safer Exports image

Fast Excel 5.x Adds Streaming Imports and Safer Exports

Read article