MySQL common built-in functions-the strtotime () function cannot be used in query statements!

Source: Internet
Author: User

From: http://yushine.iteye.com/blog/775407

From_unixtime to convert UNIX timestamps to standard Time

Unix_timestamp convert standard Time to UNIX timestamp//query statement you cannot use the Strtotime () function! But you can use the Unix_timestamp

Date_format (' 1997-10-04 22:23:00 ', '%y-%m-%d ') format time

such as: Select From_unixtime (pubdate) from article where pubdate >unix_timestamp (' 2007-10-27 00:00:00 ');

Date is the parameter that needs to be processed (the parameter is a UNIX timestamp), can be a field name, or it can be a Unix timestamp string
The following '%y%m%d ' is primarily the formatting of the return value
For example:
Mysql>select from_unixtime (1195488000, '%y%m%d ')
->20071120
Mysql>select from_unixtime (1195488000, '%y year%m Month%d ')//Remember to add "%"
->2007 Year November 20
Unix_timestamp () is a time function that is opposite to it
For example:
mysql> SELECT unix_timestamp (' 2007-11-20 ');
->1195488000

MySQL common built-in functions-the strtotime () function cannot be used in query statements!

Related Article

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.