MySQL TO_SECONDS() Function
In MySQL, the TO_SECONDS() function converts the specified date/datetime to seconds since year 0 and returns the result.
TO_SECONDS() Syntax
Here is the syntax of MySQL TO_SECONDS() function:
TO_SECONDS(date_or_datetime)
Parameters
date_or_datetime- Required. A date or datetime value.
Return value
The MySQL TO_SECONDS() unction converts the specified date/datetime to seconds since year 0 and returns the result.
If the argument is NULL, the TO_SECONDS() function will return NULL.
TO_SECONDS() Examples
Here are some examples of the TO_SECONDS() function.
SELECT
TO_SECONDS('2022-02-28'),
TO_SECONDS('2022-02-28 10:10:10');
+--------------------------+-----------------------------------+
| TO_SECONDS('2022-02-28') | TO_SECONDS('2022-02-28 10:10:10') |
+--------------------------+-----------------------------------+
| 63813225600 | 63813262210 |
+--------------------------+-----------------------------------+