mysql unix timestamp to date 1

mysql unix timestamp to date

SELECT FROM_UNIXTIME(1447430881); 
	# 2015-11-13 10:08:01
SELECT FROM_UNIXTIME(1632406597); 
	# 2021-09-23 16:16:37
SELECT FROM_UNIXTIME(1447430881,'%Y %D %M %h:%i:%s %x'); 
	# 2015 13th November 10:08:01 2015

Here is what the above code is Doing:
1. The first SELECT statement converts the UNIX timestamp 1447430881 (which is the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified) into a datetime value.
2. The second SELECT statement converts the UNIX timestamp 1632406597 (which is the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified) into a datetime value.
3. The third SELECT statement converts the UNIX timestamp 1447430881 (which is the number of seconds between the Unix Epoch (January 1 1970 00:00:00 GMT) and the time specified) into a datetime value, and then uses the %Y, %D, %M, %h, %i, %s, and %x format specifiers to format the datetime value as a string.

Similar Posts