SEC_TO_TIME
SEC_TO_TIME is a function in SQL that converts a given number of seconds into a time value in the format of 'HH:MM:SS'.
SEC_TO_TIME(seconds)
- seconds: This is an expression that will be converted into seconds. It must be a positive integer of numeric type measuring the time duration in seconds. The output will be a string formatted as “hh
Example
Output
Explanation
The SEC_TO_TIME function in MySQL converts a number, provided as input, into time format (hours, minutes, and seconds). In the example, the input 3661 seconds is converted to ‘01:01:01’, representing 1 hour, 1 minute, and 1 second.