How to use UNIX_TIMESTAMP function in MySQL
MySQL how to use UNIX_TIMESTAMP function, I believe that many inexperienced people are helpless about this, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.
The UNIX_TIMESTAMP function in MySQL has two types to call
1 No argument call: UNIX_TIMESTAMP()
Return value: Seconds difference from '1970-01-01 00:00:00' to current time
UNIX SELECT_TIMESTAMP() => 1339123415
UNIX_TIMESTAMP(date)
where date can be a DATE string, a DATETIME string, a TIMESTAMP, or a number in YYMMDD or YMMDD format for local time
Return value: Seconds difference from '1970-01-01 00:00:00' to specified time
Example: www.2cto.com
DATE string format: (date type)
SELECT UNIX_TIMESTAMP(‘2012-06-08’) => 1339084800
SELECT UNIX_TIMESTAMP(CURRENT_DATE()) =>1339084800
Note: The return value of CURRENT_DATE () is a DATE string format
The following formats return the same result:
SELECT UNIX_TIMESTAMP('20120608');
SELECT UNIX_TIMESTAMP('2012-6-8');
SELECT UNIX_TIMESTAMP('2012-06-08');
The result is: 1339084800
DATETIME string format: (combined type of date and time)
SELECT UNIX_TIMESTAMP(‘2012-06-08 10:48:55’) => 1339123415
SELECT UNIX_TIMESTAMP(NOW()) => 1339123415
Note: The return value of NOW() is a DATETIME string format
After reading the above, do you know how to use UNIX_TIMESTAMP function in MySQL? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!