Mysql convert unix timestamp to human readable format
Mysql and Unix timestamps are numerical values representing number of seconds elapsed since 1st of January 1970.
Mysql: How to get timestamp of current time:
Code:
mysql> select UNIX_TIMESTAMP();
+------------------+
| UNIX_TIMESTAMP() |
+------------------+
| 1421249658 |
+------------------+
1 row in set (0.00 sec)
Mysql: How to convert unix timestamp to human readable format:
Code:
mysql> select FROM_UNIXTIME(UNIX_TIMESTAMP());
+---------------------------------+
| FROM_UNIXTIME(UNIX_TIMESTAMP()) |
+---------------------------------+
| 2015-01-14 17:34:49 |
+---------------------------------+
1 row in set (0.00 sec)
Note that timestamp involving functions in Mysql contain unix as this format is unix time format. More info about mysql date and time functions on mysql website:
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html