Re: Week Days

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



benc11@xxxxxxxxx wrote:
I am trying to add 3 (or a user-defined amount) week days to a certain date.. An example is today 2005-08-18 then adding 3 week days to give me a date of 2005-08-23. I have tried searching online but cannot find an easy way of doing so.

$numDaysToAdd = 3;
$s = ($numDaysToAdd == 1) ? '' : 's';

$dayInFuture = strtotime("+$numDaysToAdd day$s");
$dayName = date('l', $dayInFuture);
if($dayName == 'Saturday') {
	$dayInFuture = strtotime("+2 days", $dayInFuture);
} else if($dayName == 'Sunday') {
	$dayInFuture = strtotime("+1 day", $dayInFuture);
}

Disclaimer: untested code.

Jasper

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux