PHP currently only supports RFC 2822 and ISO 8601 compliance dates, as well as Unix timestamps. More details here .
The reason for this is probably because they include a time zone offset, and the βmysql formβ - its localized compilation format - doesnt, which often leads to confusion when used with application servers.
But you can define your own formats as you wish, all components are available through the datetime functions. Just look here and here.
Example:
$mysql_date = date('Ymd H:i:s', $unix_timestamp);
But remember the Y2k38 bug , if you are not using a 64-bit system, you can use the datetime class
source share