MySQL SEC_TO_TIME() Function

In MySQL, the SEC_TO_TIME() function converts the specified number of seconds to a time value in HH:MM:SS format.

SEC_TO_TIME() Syntax

Here is the syntax of MySQL SEC_TO_TIME() function:

SEC_TO_TIME(seconds)

Parameters

seconds
Required. The number of seconds.

Return value

The MySQL SEC_TO_TIME() function converts the specified number of seconds to a time value in HH:MM:SS format.

The SEC_TO_TIME() function will return NULL if the argument is NULL.

SEC_TO_TIME() Examples

Here are some examples of the SEC_TO_TIME() function.

SELECT
    SEC_TO_TIME(100),
    SEC_TO_TIME(3600),
    SEC_TO_TIME(-72000);
+------------------+-------------------+---------------------+
| SEC_TO_TIME(100) | SEC_TO_TIME(3600) | SEC_TO_TIME(-72000) |
+------------------+-------------------+---------------------+
| 00:01:40         | 01:00:00          | -20:00:00           |
+------------------+-------------------+---------------------+