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 );

Topics:

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

{{ parent.tldr }}

{{ parent.urlSource.name }}