Name
TIME_TO_SEC( )
Synopsis
TIME_TO_SEC(time
)
This
function returns the number of seconds that the given time
represents. This function is the inverse of SEC_TO_TIME()
.
SELECT TIME_TO_SEC('01:00') AS 'Seconds up to 1 a.m.'; +----------------------+ | Seconds up to 1 a.m. | +----------------------+ | 3600 | +----------------------+
Here we’re calculating the number of seconds up until the time of 1 a.m. (i.e., 60 seconds times 60 minutes) or one hour into the day.
Get MySQL in a Nutshell 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.