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

Fathom Analytics | Fast, simple and privacy-focused website analytics. Fathom Analytics | Fast, simple and privacy-focused website analytics.
Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future. Achieve superior email deliverability with ToastMail! Our AI-driven tool warms up inboxes, monitors reputation, and ensures emails reach their intended destination. Sign up today for a spam-free future.
Community Partners