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($
Simpler ->
if(strtotime($this->day) < strtotime(date('Y-m-d')))
{
...
}
else
{
...
}
if(strtotime($this->day) < mktime(0, 0, 0)){
// date is past
} else {
// date is not past
}
A timestamp never contains only the date, but is always down to the current second. strtotime($this->day)
is going to return today's date at 0:00
, while you are comparing it against now, say, 11:12
.
You could use strtotime("$this->day 12:59:59pm");
(if the format of $this->day
allows for that) or use tomorrow's timestamp.