Search code examples
phptimezonetimestamp-with-timezone

Will php timezone always be there?


I'm trying to integrate PHP's date time and timezone features into my applications. What I have working now:

  • Every time is stored in the database as a Unix timestamp
  • Every time manipulation is all done using the timestamp
  • The only time it exists as a user-friendly format is right when it is displayed to the user

Yes, I know MySQL has an internal date time primitive object, but I don't fully understand how it works, and it just seems like a pain storing time in that format.

I also wrote my own very simple timezone library, consisting of literal (-12, 11) hour offsets with some friendly name assigned to each of the offsets. This is supposed to be changed later on to a full fledged timezone library, because I know the pains of creating a new timezone library (https://www.youtube.com/watch?v=-5wpm-gesOY). I have tried PHP's internal timezone library and everything seems to work perfectly.

There is a canonical list of timezones provided by PHP that can be accessed at DateTimeZone::listIdentifiers(). I sort of expect PHP itself will communicate with some outside time keeping database to change the timezones dynamically if any country changes its timezone details. My question is, does this actually happen? If it does happen, is there any guarantee that a specific timezone (say America/Guatemala) will still be recognized by PHP over time and not throw an error when timezones change?


Solution

  • As you can see here, PHP is pretty much alive and will be maintained over the next years. So if a change will be done, it will be communicated at the earliest point. In the last releases things have been marked es deprecated, before they 've been completely removed in a following version. So if a timezone constant will be removed, you will be informed in a future version with a deprecated notice. No componend will be removed without marking it at deprecated before removing. Doing so enables you to have much more time than you need to find a solution.