MySQL UNIX_TIMESTAMP is one of the Date Functions, which returns the seconds from 1970-00-00 00:00:00 UTC. This method accepts the date in YYMMDD, YYYYMMDD, YYMMDDHHMMSS, or YYYYMMDDHHMMSS formats.
Let us see how to use this UNIX_TIMESTAMP function to get the seconds from 1970 to Date with an example.
MySQL UNIX_TIMESTAMP Syntax
The basic syntax of the UNIX_TIMESTAMP Function is as shown below:
UNIX_TIMESTAMP();
UNIX_TIMESTAMP(date);
If you used the Date argument and specified any Date value. Then this method returns the seconds from 1970-00-00 00:00:00 to the user given date.
MySQL UNIX_TIMESTAMP function Example
The following examples help you understand the use of the Unix Timestamp method. Here, we are returning the Seconds from 1970 to the different dates. Also, read about the MySQL FROM_UNIXTIME function.
SELECT UNIX_TIMESTAMP();
SELECT UNIX_TIMESTAMP(NOW());
SELECT UNIX_TIMESTAMP('2019-02-25');

UNIX TIMESTAMP Example 2
Let us see another example of this method. Here, we are using MySQL NOW, MySQL CURDATE, along with some additional operations inside this method. It means we are using MySQL DateTime in String format.
SELECT UNIX_TIMESTAMP(NOW() + 20);
SELECT UNIX_TIMESTAMP(CURDATE() + 2);
SELECT UNIX_TIMESTAMP('2018-12-31 23:59:59');

Let us see another Date Function example of the Unix Timestamp.
TIP: Please refer to the MySQL TO_SECONDS and MySQL TO_DAYS functions from the list of available MySQL Date functions.
SELECT UNIX_TIMESTAMP('20181231');
SELECT UNIX_TIMESTAMP('20181231235959');
