Summary of using the unix_timestamp function in MySQL

Source: Internet
Author: User

The unix_timestamp function in MySQL has two types for calling.

1 No parameter call: unix_timestamp ()

Returned value: the difference in the number of seconds from '2017-01-01 00:00:00 'to the current time

Example: Select unix_timestamp () => 1339123415

2 parameter calls: unix_timestamp (Date)

Here, date can be a date string, A datetime string, a timestamp, or a number in the yymmdd or yyymmdd format of the local time

Returned value: the difference between '2017-01-01 00:00:00 'and the specified time in seconds

Example:

Date string format: (date type)

Select unix_timestamp ('2017-06-08 ') => 2012

Select unix_timestamp (current_date () = & gt; 1339084800

Note: The returned value of current_date () is a date string format.

The returned results are the same in the following formats:

Select unix_timestamp ('20140901 ');

Select unix_timestamp ('2017-6-8 ');

Select unix_timestamp ('2017-06-08 ');

Results: 1339084800

 

Datetime string format: (combination type of date and time)

Select unix_timestamp ('2017-06-08 10:48:55 ') => 2012

Select unix_timestamp (now () = & gt; 1339123415

Note: The Return Value of now () is a datetime string format.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.