Skip to content
Advertisement

MySQL: Convert relative seconds count to datetime?

I have a MySQL database show uptime for devices. The uptime is how long the device has been up in seconds. I have a query showing all devices with uptime less than 86400 (24 hours) which I want to bring into a PHP page.

I want to format this uptime string number into a datetime that’s human readable. Here is my query:

How can I turn that 10329 into an actual time? I assume there is some sort of value that can pull the current time in seconds, minus that uptime value, and convert that into MM/DD/YYYY HH:MM:SS readable value?

Any help is great appreciated!

EDIT: Decided to use both answer below, but here is the query that fits my needs:

Which returns:

Advertisement

Answer

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement