Php Chinese network (www.php.cn) provides the most comprehensive basic tutorial on programming technology, introducing HTML, CSS, Javascript, Python, Java, Ruby, C, PHP, basic knowledge of MySQL and other programming languages. At the same time, this site also provides a large number of online instances, through which you can better learn programming... UNIX_TIMESTAMP (), UNIX_TIMESTAMP (date)
If no parameter is called, a Unix timestamp ('2017-01-01 00:00:00 'seconds after GMT) is returned as an unsigned integer. If you use date to call UNIX_TIMESTAMP (), it will return the parameter value in the form of the number of seconds after '2017-01-01 00:00:00 'GMT. Date can be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the YYMMDD or YYYMMDD format of the local time.
mysql> SELECT UNIX_TIMESTAMP(); -> 882226357 mysql> SELECT UNIX_TIMESTAMP('1997-10-04 22:23:00'); -> 875996580
When UNIX_TIMESTAMP is used in the TIMESTAMP column, the function returns an internal timestamp value without any implicit conversion of "string-to-Unix-TIMESTAMP. If you pass an overflow date to UNIX_TIMESTAMP (), it returns 0, but note that only the basic range check will be executed (year from 1970 to 2037, month from 01 to 12, from 01 to 31 ).
Example of mutual conversion between timestamp and time in PHP:
PHP code
$ Timestamp = 1210003200; $ datetime = date ('Y-m-d H: I: S', $ timestamp); echo "the time stamp represents :", $ datetime ,"
\ N "; echo" returns the timestamp from this time: ", strtotime ($ datetime ),"
\ N ";
Example of timestamp conversion in MySQL:
SQL code
select from_unixtime(1210003200) datetime, unix_timestamp(from_unixtime(1210003200)) timestamp;