Why can't we use the TIMESTAMP data type for fields created and modified in cakephp2.x?

As we know, the datetime data type MYSQL takes up more memory than TIMESTAMP. For quick development, I use cakephp2.x. My problem is why we are not using TIMESTAMP for the created and modified field in the database. I am reading the cakephp2.x document, they do not mention the reason in technical terms clearly. Expect an expert response!

Thank you in advance

+4
source share
2 answers

The main difference is that DATETIME is constant, while TIMESTAMP depends on the setting of time_zone.

In addition, the space required for both can be considered almost identical if you do not have billions of lines (4 bytes with 8 bytes, but still nothing really). datetime fields can also be used for simple comparison and calculation.

My recommendation: so just stick to the date and time and don't create a problem where it doesn't exist. Usually there are problems with problems when developing an application.

+5
source

It has been proven several times to me that you should avoid using created and updated CakePHP automatic fields or, at most, for forensic accounting (i.e. you should never use your values ​​in your application).

It is inflexible, does not have the same settings as internationalization, and can work more efficiently.

Whenever I need to save time, I do this in the INT field as a Unix timestamp. This also works well with multiple time zones and various environments (e.g. TZ in DB and PHP).

-1
source

All Articles