Reputation: 2307
i have a table in mysql db ( created_date). It stores timestamps (INT value). I would like to print the column values in sql, what function to use for that. For he format, everything suits me.
Select WHAT_FUNCTION_TO_USE( created_date) from users
Upvotes: 2
Views: 651
Reputation: 4591
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),'%d-%m-%Y ); // dd-mm-yyyy format
or
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),'%m-%d-%Y ); // mm-dd-yyyy format
Upvotes: 1
Reputation: 31239
If you want to format the date the see this link
Like this:
SELECT FROM_UNIXTIME(1196440219);
-> '2007-11-30 10:30:19'
SELECT FROM_UNIXTIME(1196440219) + 0;
-> 20071130103019.000000
SELECT FROM_UNIXTIME(UNIX_TIMESTAMP(),
-> '%Y %D %M %h:%i:%s %x');
-> '2007 30th November 10:30:59 2007'
Upvotes: 1