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.