How to store time properly so that the timezone can be changed later with user defined timezones? How do you typically do this using the DateTime class?
For example:
You run a forum script.
Your server’s local time is US
User A is from EU
User B is from JP
User A posted and sees the time based on his local time in EU.
User B sees User A’s post on his local time in JP.
My question is what timezone should you store the time. And how do you typically do this using DateTime class?
Save the time in UTC format, for stability and consistency.
Each user should have his preference saved in the database, in the form of PHP’s known timezones.
Then, when displaying, change the time to the correct time zone.
Would yield the correct date/time for the user.