Check if a given date is past

后端 未结 3 1527
轮回少年
轮回少年 2021-01-17 14:57

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($         


        
3条回答
  •  生来不讨喜
    2021-01-17 15:35

    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.

提交回复
热议问题