Home > Article > Backend Development > mysql From_unixtime and UNIX_TIMESTAMP and DATE_FORMAT date functions_PHP tutorial
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: