MySQL TIME_TO_SEC() Function
In MySQL, the TIME_TO_SEC() function converts the specified time value to the number of seconds.
TIME_TO_SEC() Syntax
Here is the syntax of MySQL TIME_TO_SEC() function:
TIME_TO_SEC(time)
Parameters
time- Required. A time value or expression. Format:
HH:MM:SSorHH:MMorSS.
Return value
The MySQL TIME_TO_SEC() function converts the specified time value to the number of seconds.
If the argument is NULL, the TIME_TO_SEC() function will return NULL.
TIME_TO_SEC() Examples
Here are some examples of the TIME_TO_SEC() function.
SELECT
TIME_TO_SEC('10:10:10') `10:10:10`,
TIME_TO_SEC('10:10') `10:10`,
TIME_TO_SEC('10') `10`;
+----------+-------+------+
| 10:10:10 | 10:10 | 10 |
+----------+-------+------+
| 36610 | 36600 | 10 |
+----------+-------+------+