I'm looking to add a certain amount of time to a string, but skip the weekdays. So, for example if I wanted to add 40 hours to the timestamp "2014-04-03 19:33:40"
it would return "2014-04-07 11:33:40"
(having skipped the weekend).
I also need to do this with days and possibly minutes. Here is the (non-working) function I've come up with:
function expiration_date($opentime,$tfString)
{
switch($tfString)
{
case "daily" :
$expiration_date = gmdate('Y-m-d H:i:s', strtotime($opentime . ' + 10 weekdays'));
break;
case "4h":
$expiration_date = gmdate('Y-m-d H:i:s', strtotime($opentime . ' + 40 weekday hours'));
break;
case "1h":
$expiration_date = gmdate('Y-m-d H:i:s', strtotime($opentime . ' + 10 weekday hours'));
break;
case "30m":
$expiration_date = gmdate('Y-m-d H:i:s', strtotime($opentime . ' + 5 weekday hours'));
break;
case "15m":
$expiration_date = gmdate('Y-m-d H:i:s', strtotime($opentime . ' + 2.5 weekday hours'));
break;
default: $expiration_date = '0000-00-00 00:00:00';
}
return $expiration_date;
}