Over a million developers have joined DZone.

Dates In MySQL And PHP

DZone's Guide to

Dates In MySQL And PHP

Free Resource
        // $mysqldate is ready to be inserted into a DB
        // $phpdate is ready to used in a PHP script

        // For use with DATESTAMP type or TIMESTAMP type

        $mysqldate = date( 'Y-m-d H:i:s', $phpdate );

        $phpdate = strtotime( $mysqldate );

        // For use with DATE type

        $mysqldate = date( 'Y-m-d', $phpdate ); // H:i:s will be 00:00:00

        $phpdate = strtotime( $mysqldate );


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}