Drennos
Drennos

Reputation: 313

Date: get the next monday or tuesday from a date

I want to compare two dates, the system date against the date of a record, if the system date is a Thursday and the record date is a Monday, print a blinking <td>. I used 'next Mon', but it does not work

@elseif(date('D') == 'Thu' AND date('D', strtotime($crq->date)) == 'next Mon')
     <td style="background-color: black;color: white"><blink>{{ $crq->date }}<i class="fa fa-exclamation "></i></blink></td>

Upvotes: 2

Views: 302

Answers (1)

Qirel
Qirel

Reputation: 26450

date() will not output "next Mon", it might print "Mon" if the day is in fact on a Monday, but it will not print "next" (this is using the D format in date()).

You should instead check if the date is the same. You can do that by checking if the dates are exactly the same from the value in your $crq-date and strtotime("next Monday"), which is the timestamp for the next Monday.

date('Y-m-d', strtotime($crq->date)) == date("Y-m-d", strtotime("next Monday"))

Here's a live demo.

Upvotes: 2

Related Questions