Reputation: 59
I am working on my social network project.
I'm so confused with the issue related with date and time of update, comment, messages and anything wherever I am showing date and time.
Suppose I am sorting my updates using date and time. I am storing date and time in mysql
using CURDATE()
and CURTIME()
functions respectively.
Suppose, I just posted something in India on my profile at 6.40 pm. So when it shows on my London friend profile, it will show stored date and time means Indian date and time. But Indian time is ahead of the UK time. So it will show 6.40Pm for that update when current time of London is 2.10PM. So showing 6.40Pm which is not the good thing for them. So I have to show local time for that post means 2.10Pm.
Basically I want to show all updates time is less than current date and time of the user but it is impossible for updates posted by ahead time countries. So how to store and convert these date and time according users countries?
Upvotes: 0
Views: 286
Reputation: 111
You can search the timezones by country with DateTimeZone::listIdentifiers
Array
(
[0] => Atlantic/Azores
[1] => Atlantic/Madeira
[2] => Europe/Lisbon
)
you have to store user information based on location or else you cal retrieve location based LBS then set the timezone.
Upvotes: 0
Reputation: 138487
What about saving the time in Timezone 0 (Greenwich time). Add a js file that changes the provided time to the browser time by adding the timezones difference.
Upvotes: 0