Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL convert seconds to datetime

So I have an integer '63605914755' like this:

SELECT TO_SECONDS( '2015-08-04 13:40:56' )
-----
Result: '63605914755'

How do I convert '63605914755' back from seconds to datetime (Ex: '2015-08-04 13:40:56') ?

like image 630
Maxime Avatar asked Sep 15 '25 17:09

Maxime


1 Answers

SELECT
  from_unixtime(seconds - to_seconds('1970-01-01 00:00:00')) as my_date_time
FROM 
  your_table

Here is an SQLFiddle

like image 187
Mihai Matei Avatar answered Sep 18 '25 08:09

Mihai Matei