MySQL SEC_TO_TIME Function

MySQL SEC_TO_TIME is one of the Date Functions, which converts the user-given seconds into a Time value. This method returns output Time in Hours:Minutes: Seconds format, and the basic syntax of it is as shown below:

SEC_TO_TIME(Seconds);

MySQL SEC_TO_TIME Example

The below-shown queries help you understand the use of this MySQL Second to Time function. Here, we are converting different seconds values to Time.

SELECT SEC_TO_TIME(5);

SELECT SEC_TO_TIME(67);

SELECT SEC_TO_TIME(3717);
MySQL Convert seconds into a Time value Example 1

In this Date method example, we are converting seconds to time. Next, we are adding a few seconds to that output. It means MySQL returns the output in HHMMSS format.

SELECT SEC_TO_TIME(7334);

SELECT SEC_TO_TIME(7334), SEC_TO_TIME(7334) + 0;

SELECT SEC_TO_TIME(10334), SEC_TO_TIME(10334) + 22;
MySQl SEC_TO_TIME Example 2