Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert timestamp to date?

Tags:

time

mysql

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.

like image 913
Query Master Avatar asked Mar 06 '12 14:03

Query Master


2 Answers

Try with FROM_UNIXTIME(unix_timestamp,format)

FROM_UNIXTIME(1329944650, '%Y-%m-%d')
like image 119
hsz Avatar answered Nov 07 '22 18:11

hsz


To convert unix timestamp into human readable format mysql has built-in function FROM_UNIXTIME() it takes 2 parameters first is the timestamp that you want to convert and the second one is the format in which you want to convert in your case this should be

FROM_UNIXTIME('1329944650', '%Y-%m-%d');
like image 35
Code Prank Avatar answered Nov 07 '22 19:11

Code Prank