Alex Rivera | Logout

Check if a given date is past

Asked 2010-07-21T09:09:44.560
11

I have a week calendar that holds events, and want that users can't add events for the past days. So I'm tring to use a function like that:

if( strtotime($this->day) < time() ){ // date format is YYYY-MM-DD
// date is past 
}else{   
// date is not past
}

It seems to works fine, except that it consider today date as a past day. What am i doing wrong?

Edit
Report

1 Answer

0
if(strtotime($this->day) < mktime(0, 0, 0)){
    // date is past
} else {
    // date is not past
}
answered 2010-07-21T09:20:25.833

Your Answer