Name
TIME_TO_SEC()
Synopsis
TIME_TO_SEC(time
)
This function returns the number of seconds that the given time represents. It’s the inverse of SEC_TO_TIME(). Here is an example:
SELECT TIME_TO_SEC('01:00') AS 'Seconds to 1 a.m.'; +-------------------+ | Seconds to 1 a.m. | +-------------------+ | 3600 | +-------------------+
Here, we calculate the number of seconds up until 1 A.M. (i.e., 60 seconds times 60 minutes), or one hour into the day.
Get MySQL in a Nutshell, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.