php time periods without weekends
date, php
Solution
This seems to work (demo):
$date = strtotime('2012-06-01'); // Friday
echo date('Y-m-d (l)', strtotime('+1 weekdays', $date)); // 2012-06-04 (Monday)
echo date('Y-m-d (l)', strtotime('+6 weekdays', $date)); // 2012-06-11 (Monday)
echo date('Y-m-d (l)', strtotime('+8 weekdays', $date)); // 2012-06-13 (Wednesday)
echo date('Y-m-d (l)', strtotime('+9 weekdays', $date)); // 2012-06-14 (Thursday)
echo date('Y-m-d (l)', strtotime('+10 weekdays', $date)); // 2012-06-17 (Sunday)
Sorry, but I don't know what's wrong with the last one; perhaps someone else can shed some light into it.
Problem
Given the date of a day and a number (X) of days I'd need to retrieve the date after X days without considering Saturdays or Sundays. For example: ``` date1= Y-m-d -where-> Monday of the week #20 date1+2 days= Wednesday of the week #20 date2= Friday of the week #22 date2+1 day= Monday of week #23 ``` Is there some built-in function for helping with that task? or must I implement it? Thanks