What I am trying to do is I have a selected date formatted as below:
$selectedDate = 2010/02/24
I want to check it is both todays date and it is past 9pm on the server and set a value if it is.
I can get a time by using the following:
$checkTime = date("H:i");
I want to create something like:
if ($checkTime > 21:00 && $selectedDate == date("Y/m/d")) { //do my stuff }
But a bit unsure of the syntex.
Many thanks for any help
$checkDate = '2010-02-24';
$checkTime = '2100';
if( date( 'Y-m-d' ) == $checkDate && date( 'Hi' ) >= $checkTime ) {
// Do something clever
}
Note the use of Hi
as the date format string, which allows for a numerical comparison.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.