1024programmer Mysql How does mysql convert timestamp to date

How does mysql convert timestamp to date

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!

This article is from the internet and does not represent1024programmerPosition, please indicate the source when reprinting:https://www.1024programmer.com/how-does-mysql-convert-timestamp-to-date/

author: admin

Previous article
Next article

Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索