/** * Returns the timestamp for the next occurance of [day]. * * @param timestamp * @param int the day of week * @return timestamp */ public static function nextDay($ts = null, $day = sfTime::SUNDAY) { // default to now if ($ts === null) { $ts = sfDateTimeToolkit::now(); } // get offsets from sunday $offset1 = date('w', $ts); $offset2 = $day; // adjust if date wraps into next week $offset2 += $offset2 > $offset1 ? 0 : 7; return sfTime::addDay($ts, $offset2 - $offset1); }