MySQL TIME_TO_SEC Function

MySQL TIME_TO_SEC function is one of the MySQL Date Function, which converts and returns the Time argument into seconds. In this article, we show you how to use this Time To Sec function to convert time to seconds in MySQL from an expression with an example. The basic syntax of the Time to second Function in MySQL is as shown below:

TIME_TO_SEC(Time);

MySQL TIME_TO_SEC function Example

The following examples help you understand the use of Time to Second function. In this MySQL example, we are using different time values as an input for the function.

SELECT TIME_TO_SEC('10:22:30');

SELECT TIME_TO_SEC('01:00:00');

SELECT TIME_TO_SEC('23:59:59');
MySQL TIME_TO_SEC Function 1

Let us see another Date Function example of the Time to second function. Here, we are using NOW, SYSDATE, and UTC_TIME inside this TIME_TO_SEC function.

SELECT TIME_TO_SEC(NOW());

SELECT TIME_TO_SEC(SYSDATE());

SELECT TIME_TO_SEC(UTC_TIME);
MySQL TIME_TO_SEC Function 2