How does mysql convert timestamp to date
How does mysql convert timestamp to date
mysql method to convert timestamp into date: use the function [FROM_UNIXTIME()], the code is [select FROM_UNIXTIME(1429063399, & # 39; %Y year %m month %d day & # 39;) 】. Mysql converts timestamp to date: 1. Convert timestamp to date Function: FROM_UNIXTIME() select FROM_UNIXTIME(1429063399,'%YYear%mMonth%dDay' 😉 The result is: April 15, 2015 2. Convert the date to a timestamp, which is exactly the opposite of FROM_UNIXTIME Function: UNIX_TIMESTAMP() select UNIX_TIMESTAMP('2015-04-15') The result is: 1429027200 Related free learning recommendation: mysql database (video) The above is the detailed content of how mysql converts timestamps into dates. For more information, please pay attention to other related articles on 1024programmer.com !
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…