DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Dates In MySQL And PHP

08.03.2009
| 1915 views |
  • submit to reddit
                // $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 );
    

Comments

Snippets Manager replied on Wed, 2009/12/09 - 6:13pm

Just the thing I was looking for. Thanks!