Home > Database > Mysql Tutorial > mysql how to convert timestamp to date

mysql how to convert timestamp to date

coldplay.xixi
Release: 2020-11-18 09:27:56
Original
8024 people have browsed it

Mysql method of converting timestamp to date: If you use date to call [UNIX_TIMESTAMP()], it will change the parameter value to seconds after ['1970-01-01 00:00:00' GMT] Returned as a number.

mysql how to convert timestamp to date

Mysql method of converting timestamp to date:

mysql query timestamp (TIMESTAMP) into commonly used Reading time format

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, It can also 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, '%Y年%m月%d' ) 
->2007年11月20 
UNIX_TIMESTAMP()是与之相对正好相反的时间函数
UNIX_TIMESTAMP(), UNIX_TIMESTAMP(date)
Copy after login

If there are no parameters When called, a Unix timestamp (the number of seconds after '1970-01-01 00:00:00' 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 seconds after '1970-01-01 00:00:00' GMT. date can be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the local time format of YYMMDD or YYYMMDD.

For example:

mysql> SELECT UNIX_TIMESTAMP() ; (执行使得时间:2009-08-06 10:10:40) 
->1249524739 
mysql> SELECT UNIX_TIMESTAMP('2009-08-06') ; 
->1249488000
Copy after login

More related free learning recommendations:mysql tutorial(Video )

The above is the detailed content of mysql how to convert timestamp to date. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
Statement of this Website
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
Latest Issues
MySQL stops process
From 1970-01-01 08:00:00
0
0
0
Error when installing mysql on linux
From 1970-01-01 08:00:00
0
0
0
phpstudy cannot start mysql?
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template