Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php get today tomorrow and next day but ignore weekends

Tags:

date

php

How can I get the current day, tomorrow and next day in PHP but ignore weekends?

I have already tried this code, but it will include Saturday and Sunday.

array(
    'todayDate' => date('d/m/Y')
    'tomorrowDate' => date('d/m/Y', strtotime(' +1 day')),
    'nextDay' => date('l', strtotime(' +2 day'))
)

Thanks.

like image 966
V4n1ll4 Avatar asked Jun 10 '15 06:06

V4n1ll4


2 Answers

Use Weekday(s) with strtotime

date('l', strtotime(' +2 Weekdays'));

Fiddle

like image 144
Hanky Panky Avatar answered Nov 04 '22 04:11

Hanky Panky


This finds the next weekday from a specific date (not including Saturday or Sunday):

echo date('Y-m-d', strtotime('2011-04-05 +2 Weekday'));

You could also do it with a date variable of course:

$myDate = '2011-04-05';
echo date('Y-m-d', strtotime($myDate . ' +2 Weekday'));
like image 33
Deep Kakkar Avatar answered Nov 04 '22 04:11

Deep Kakkar