What is the best way to handle dates and times in PHP prior to 5.3?

Well, it turned out that I built a relatively large program built on top of DateTime, only to find most of what I used there was added in PHP 5.3. The server I must deploy to does not work 5.3. (And this is the Ubuntu Hardy field (8.04), which does not have package 5.3 in the main repo, and I am not allowed to install anything other than in the main repositories in this field ...)

+3
source share
2 answers

When transferring data around, I prefer to use unix timestamps. If you have a different view, you can use strtotime () to convert it.

There are several functions that come in handy when working with dates and times. this is similar to what is done with a DateTime object, with some combinations of these methods:

also, just an explanation of your terminology, the unix era is the moment when all unix timestamps are counted, which is midnight, December 31, 1969.

+2
source

Always use unix timestamps as int for date / time regardless of mysql version.

0
source

Source: https://habr.com/ru/post/1766481/


All Articles