Pierrick Flajoulot Pierrick Flajoulot - 6 months ago 22
PHP Question

Get date of next thursday (including today if we are thursday)

I need to get the date of the next thursday.
So far, I'm using

strtotime('next thursday');
to got it. It worked well until I realise it gives me the date of thursday next week if we are thursday today...

What would be the best way to get the next thursday including today's date in calculation ?


You can try this:

if((int) date('N') === 4) {
    return date('Y-m-d'); // today is thursday
else {
    return date('Y-m-d', strtotime('next thursday'));