Linux, FreeBSD, Juniper, Cisco / Network security articles and troubleshooting guides
https://forum.ivorde.com/

Mysql convert unix timestamp to human readable format
https://forum.ivorde.com/mysql-convert-unix-timestamp-to-human-readable-format-t19631.html
Page 1 of 1

Author:  mandrei99 [ Wed Jan 14, 2015 11:36 am ]
Post subject:  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

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/