THINKPHP time comparison

Source: Internet
Author: User
Select a time period for THINKPHP time comparison problems, for example, 2014-03-15 & nbsp; 03:12:43 & nbsp; to & nbsp; 03:12:43 data in this time period, the front-end page is entered in the form of 2014-03-15, the database is in the format of & nbsp; 03:12:43, with more time minutes and seconds, I compare the time of 201 THINKPHP
Select a time period, for example, data from 03:12:43 to 03:12:43, the front-end page is in the form of, and the database is in the form of 03:12:43, with more time minutes and seconds, 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?
------ 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 ')

------ Solution --------------------
 $ Zero1 = "00:00:00 ";
$ Zero2 = "03:12:43 ";
Echo "zero1 Time:". $ zero1 ."
";
Echo "zero2 Time:". $ zero2 ."
";
If (strtotime ($ zero1)
Echo "zero1 earlier than zero2 ";
} Else {
Echo "zero2 earlier than zero1 ";
}
?>

------ Solution --------------------
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.