THINKPHP time comparison problem

Source: Internet
Author: User
THINKPHP time comparison problem select a time period, such as 03:12:43 to 03:12:43 this time period of data, the front-end page is entered in the form of 2014-03-15, and the database is 03:12:43 this form, with more time and minutes, I added the field to the form 00:00:00, and then compared it with the time field of the database, it cannot be compared with the size. What is the correct comparison method?


Reply to discussion (solution)

Time comparison must be a unified type
Your database is datatime and the input is date.
Therefore, you need to convert datatime into date for comparison.
Date_format (time field, '% Y-% m-% d') =' $ iuput'

Yes.
To_days (time field) = to_days ('$ input ')

Time comparison must be a unified type
Your database is datatime and the input is date.
Therefore, you need to convert datatime into date for comparison.
Date_format (time field, '% Y-% m-% d') =' $ iuput'

Yes.
To_days (time field) = to_days ('$ input ')
The database field is datetime, which queries many records. Can I convert date to datetime?

No
The two data with different precision must be compared according to the low precision.

 "; Echo" zero2 Time: ". $ zero2 ."
"; If (strtotime ($ zero1)

Yes, the landlord's method is correct.

The time is relatively consistent with the timestamp, so is the database...

Well, the method is correct. you don't need to change the time format to compare the quotation marks.

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.