Pierrick Flajoulot Pierrick Flajoulot - 1 month ago 4
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 ?

Answer

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'));
}
Comments