There are programming instances in which we would need a given time to be converted to seconds to be used for certain operations.
MySQL provides an inbuilt function named TIME_TO_SEC, that accepts time as a parameter. The returned value is in seconds, computed from 00:00:00.
Consider the SQL query below to understand further.
SELECT TIME_TO_SEC('00:1:12');
This is 1 minute and 12 seconds which when converted to seconds is 60+12=72 seconds.
Output:
+-------------------------+ | TIME_TO_SEC('00:1:12') | +-------------------------+ | 72 | +-------------------------+
Now, consider the second example.
SELECT TIME_TO_SEC('23:59:59');
Output:
+-------------------------+ | TIME_TO_SEC('23:59:59') | +-------------------------+ | 86,399 | +-------------------------+