PHP and MySQL syntax: Difference between revisions

Jump to navigation Jump to search
Line 2: Line 2:
== timestamp ==
== timestamp ==
=== now ===
=== now ===
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", time() ); //Convert the time stamp of current time to the human readable time format. Ex: return '2010-12-21 10:05:06'
* php: echo date("y-m-d H:i:s", time() ); //Convert the time stamp of current time to the human readable time format. Ex: return '2010-12-21 10:05:06'
* mysql:  
* mysql:  
Line 9: Line 9:
** SELECT CURRENT_TIMESTAMP;  
** SELECT CURRENT_TIMESTAMP;  


the current timestamp ex: 1292897201
the current '''timestamp''' ex: 1292897201
* php: echo time();
* php: echo time();
* mysql: SELECT UNIX_TIMESTAMP(); //2011-05-30 01:56:38 returns 1306720622
* mysql: SELECT UNIX_TIMESTAMP(); //2011-05-30 01:56:38 returns 1306720622
* javascript: [http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript datetime - How do you get a timestamp in JavaScript? - Stack Overflow] {{access | date = 20110323}}
* javascript: [http://stackoverflow.com/questions/221294/how-do-you-get-a-timestamp-in-javascript datetime - How do you get a timestamp in JavaScript? - Stack Overflow] {{access | date = 20110323}}
compare the timestamp and human readable time format
SELECT UNIX_TIMESTAMP( ) , FROM_UNIXTIME( UNIX_TIMESTAMP( ) ,  '%Y-%m-%d %H:%i:%S' );


=== specified time ===
=== specified time ===

Navigation menu