Over a million developers have joined DZone.

Dates In MySQL And PHP

        // $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.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

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

{{ parent.tldr }}

{{ parent.urlSource.name }}