This tutorial explains how to use the MySQL SEC_TO_TIME function with syntax and examples.
The MySQL SEC_TO_TIME function converts numeric seconds into a time value.
The syntax for the SEC_TO_TIME function in MySQL is:
SEC_TO_TIME( seconds )
A numeric value representing the number of seconds. This value can be positive or negative.
The SEC_TO_TIME function can be used in the following versions of MySQL:
Let's look at some MySQL SEC_TO_TIME function examples and explore how to use the SEC_TO_TIME function in MySQL.
For example:
mysql> SELECT SEC_TO_TIME(1);
Output: '00:00:01'
mysql> SELECT SEC_TO_TIME(2);
Output: '00:00:02'
mysql> SELECT SEC_TO_TIME(8001);
Output: '02:13:21'
mysql> SELECT SEC_TO_TIME(34562);
Output: '09:36:02'
mysql> SELECT SEC_TO_TIME(-7005);
Output: '-01:56:45'