Home  >  Article  >  Backend Development  >  mysql From_unixtime and UNIX_TIMESTAMP and DATE_FORMAT date functions_PHP tutorial

mysql From_unixtime and UNIX_TIMESTAMP and DATE_FORMAT date functions_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:39:541171browse

from_unixtime() is the time function in MySQL
date is the parameter that needs to be processed (the parameter is a Unix timestamp), which can be a field name or directly the '%Y%' after the Unix timestamp string
m%d' mainly formats the return value
For example:
mysql>SELECT FROM_UNIXTIME( 1249488000, '%Y%m%d' )
->20071120
mysql>SELECT FROM_UNIXTIME( 1249488000, '%Y year %m month %d' )
->November 20, 2007
UNIX_TIMESTAMP() is the opposite time function

UNIX_TIMESTAMP(), UNIX_TIMESTAMP (date)

If called without parameters, a Unix timestamp (the number of seconds after '1970-01-01 00:00:00' GMT) is returned as an unsigned integer. If UNIX_TIMESTAMP() is called with date, it will return the parameter value as the number of seconds after GMT '1970-01-01 00:00:00'. date can be a DATE string, a DATETIME string, a TIMESTAMP, or a local time number in YYMMDD or YYYMMDD format.

For example:

Copy code The code is as follows:

mysql> SELECT UNIX_TIMESTAMP(); (Execution makes Time: 2009-08-06 10:10:40)
->1249524739
mysql> SELECT UNIX_TIMESTAMP('2009-08-06') ;
->1249488000

SELECT *
FROM `student`
WHERE regTime > UNIX_TIMESTAMP( curdate( ) ) //All student registration records today.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/321483.htmlTechArticlefrom_unixtime() is the time function in MySQL. date is the parameter that needs to be processed (the parameter is the Unix timestamp), It can be a field name, or it can be directly the '%Y%m%d' after the Unix timestamp string. Mainly...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn