Mysql converts timestamp to date: If you use date to call 【UNIX_TIMESTAMP()】, it will convert the parameter value to 【'1970-01-01 00:00:00' GMT] returned in seconds.
Mysql converts timestamp to date method:
mysql query timestamp (TIMESTAMP) into Commonly readable time format
from_unixtime()
is a time function in MySQL
date is the parameter to be processed (the parameter is a Unix timestamp), It can be a field name, or it can be directly '%Y%m%d'
after the Unix timestamp string, mainly to format the return value
For example:
mysql>SELECT FROM_UNIXTIME( 1249488000, '%Y%m%d' ) ->20071120 mysql>SELECT FROM_UNIXTIME( 1249488000, '%YYear%mMonth%d' ) ->November 20, 2007 UNIX_TIMESTAMP() is the opposite time function UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date)
If called with no arguments, returns a Unix timestamp ('1970-01-01 00:00:00' seconds since GMT) as unsigned integer. If date is used to call UNIX_TIMESTAMP()
, it will return the parameter value as the number of seconds after '1970-01-01 00:00:00' GMT. date can be a DATE string, a DATETIME string, a TIMESTAMP
, or a number in YYMMDD
or YYYMMDD
format for local time.
For example:
mysql> SELECT UNIX_TIMESTAMP() ; (Execution time: 2009-08-06 10:10:40) ->1249524739 mysql> SELECT UNIX_TIMESTAMP('2009-08-06') ; ->1249488000
More related free learning recommendations:mysql tutorial(video)
The above is the detailed content of how mysql converts timestamp to date. For more information, please pay attention to other related articles on 1024programmer.com!