You are here:
» Difference Between Mysql Date And PHP Data?
Difference between Mysql date and PHP data?
This Comment will be submitted for moderation and will not be accessible to other users until it has been approved.
I often get confused on mysql and php date time. Can anybody help me with easy to remember pointers?

1 year 41 weeks ago
Tags:
Following code would help you understand the difference between mysql time and php time or date.
<?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 );
?>
Post Comment