Laravel 5.3 : Setting time zones based on users lo

2019-07-15 05:43发布

问题:

We have small blog application in Laravel 5.3 in which i need some suggestion about setting time stamps on the following features

1.Admin can able to send notifications to all users with current time stamp (server timezone is Asia/Calcutta) user will see all the notifications based on their time zones.

2.Users can add posts along with their current time stamps , when other users see that posts based on their time zones.

So what are the changes i need to do on the timezone settings in my application??

回答1:

You might have already found an answer to your 7 months old question. Anyway, I am just posting here what I did to get rid of different time zone issue.

First read Timo Huovinen answer.

In my application, user should manually set the timezone. Based on it, convert MySQL time to appropriate timezone before sending it to client.

You can use convert_tz() function to convert between timezones.