How to convert timestamp to datetime in MySQL?

compile-fan picture compile-fan · Mar 19, 2011 · Viewed 246k times · Source

How to convert 1300464000 to 2011-03-18 16:00:00 in MySQL?

Answer

Richard Tuin picture Richard Tuin · Mar 19, 2011

Use the FROM_UNIXTIME() function in MySQL

Remember that if you are using a framework that stores it in milliseconds (for example Java's timestamp) you have to divide by 1000 to obtain the right Unix time in seconds.