PHP and MySQL syntax: Difference between revisions

Jump to navigation Jump to search
Line 17: Line 17:
the human readable time format ex: 2010-12-21 10:05:06
the human readable time format ex: 2010-12-21 10:05:06
* php: echo date("y-m-d H:i:s", 1292897201 ); // convert the time stamp 1292897201 to the human readable time format
* php: echo date("y-m-d H:i:s", 1292897201 ); // convert the time stamp 1292897201 to the human readable time format
* mysql: ? {{Exclaim}}
* mysql:
** SELECT FROM_UNIXTIME( 1306311155 ); //convert the time stamp 1306311155 to the human readable time format 2011-05-25 08:12:11
** SELECT FROM_UNIXTIME( 1306311155, '%Y-%m-%d %H:%i:%S' ); //convert the time stamp 1306311155 to the human readable time format 2011-05-25 08:12:11


convert human-readable time to timestamp
convert human-readable time to timestamp
* php:[http://php.net/manual/en/function.strtotime.php strtotime()]
* php:[http://php.net/manual/en/function.strtotime.php strtotime()]
* mysql: select UNIX_TIMESTAMP('2011-03-15 18:53:57'); /* return timestamp: 1300186437 */
* mysql: SELECT UNIX_TIMESTAMP('2011-03-15 18:53:57'); /* return timestamp: 1300186437 */


=== time difference of two time values ===
=== time difference of two time values ===

Navigation menu