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