Category: Laravel, Laravel

Step 1 In table “users”, add new column named “timezone”, with type varchar to store user’s timezone:- You can create migration file then do migrate (https://laravel.com/docs/7.x/migrations#generating-migrations)- Or simply run this sql command: Step 2Way Automatically update timezones when user login In App\Http\Controllers\Auth\LoginController, override authenticated function: In above snippet, we used Laravel Http Client and a third party service (https://ip-api.com/) to get user’s timezone from his IP address, then save it to database.

Note: To save response time of login requests, you can create new Laravel job and do necessary task there

then modify the register controller and user model if needed to store timezone once user hit register button Step 3In blade files, call setTimezone method to display datetime in user’s timezoneExample: Good luck!
Newsletter

Get the latest Laravel/PHP jobs, events and curated articles straight to your inbox, once a week

Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge. Glimpse streamlines Laravel development by seamlessly deploying GitHub pull requests to preview environments with the help of Laravel Forge.
Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Shirts painstakingly handcrafted by under-caffeinated developers. Shirts painstakingly handcrafted by under-caffeinated developers.
Community Partners