Mysql time conversion error

how to convert this time 1329944650 to this time 2011-1-2 using mysql 

I just want to know how to change mktime to this date (2011-01-2) using mysql, can you help me?

+6
source share
4 answers

To convert a unix timestamp to a user-readable format, mysql has a built-in function FROM_UNIXTIME (), first it takes 2 parameters, this is the timestamp you want to convert, and the second is the format you want to convert to in your case

 FROM_UNIXTIME('1329944650', '%Y-%m-%d'); 
+4
source

Try FROM_UNIXTIME(unix_timestamp,format)

 FROM_UNIXTIME(1329944650, '%Y-%m-%d') 
+6
source

Functions FROM_UNIXTIME and DATE.

 select DATE(FROM_UNIXTIME('1329944650')) 

 mysql> select DATE(FROM_UNIXTIME('1329944650')); +-----------------------------------+ | DATE(FROM_UNIXTIME('1329944650')) | +-----------------------------------+ | 2012-02-23 | +-----------------------------------+ 1 row in set (0.00 sec) 
+3
source

I want this format, and I got my answer, thanks to all of us

SELECT FROM_UNIXTIME(1329944650, '%Y-%m-%d %h:%i:%s') AS created_date

+1
source

Source: https://habr.com/ru/post/910089/


All Articles