/** * * @param timestamp $timestamp * @param int $amount number of days to go ahead * @param int $limit give as hours when day ends and is considered as next day * @return timestamp */ function get_bank_days($timestamp, $amount, $limit=0) { if($limit && date("H", $timestamp) > $limit) $timestamp = strtotime("+1 days", $timestamp); for($j=0; $j<$amount; $j++) { if(date("N", $timestamp) >= 6) // skip saturday & sunday $timestamp = strtotime("next Monday", $timestamp); $timestamp = strtotime("+1 days", $timestamp); } if(date("N", $timestamp) >= 6) // skip saturday & sunday $timestamp = strtotime("next Monday", $timestamp); return $timestamp; } // testata voi tällä: /* setlocale(LC_TIME, "fi_FI"); for($i=0; $i<365; $i++) { $tms = strtotime("+$i days", strtotime("2009-01-01 14:00")); $payday = get_bank_days($tms, 2, 16); echo strftime("%d.%m.%Y (%A)", $tms) ." => maksupäivä: ". strftime("%d.%m.%Y (%A)", $payday) ."
\n"; } */