Вопрос по php – Найти каждое воскресенье между двумя датами

3

Error: User Rate Limit Exceeded$fromdateError: User Rate Limit Exceeded$todateError: User Rate Limit Exceeded$fromdateError: User Rate Limit Exceeded$todateError: User Rate Limit Exceeded

Error: User Rate Limit Exceeded Welbog
Error: User Rate Limit Exceeded Beska

Ваш Ответ

4   ответа
8

Error: User Rate Limit Exceeded

function getDateForSpecificDayBetweenDates($startDate, $endDate, $weekdayNumber)
{
    $startDate = strtotime($startDate);
    $endDate = strtotime($endDate);

    $dateArr = array();

    do
    {
        if(date("w", $startDate) != $weekdayNumber)
        {
            $startDate += (24 * 3600); // add 1 day
        }
    } while(date("w", $startDate) != $weekdayNumber);


    while($startDate <= $endDate)
    {
        $dateArr[] = date('Y-m-d', $startDate);
        $startDate += (7 * 24 * 3600); // add 7 days
    }

    return($dateArr);
}

Error: User Rate Limit Exceeded

$dateArr = getDateForSpecificDayBetweenDates('2010-01-01', '2010-12-31', 0);

print "<pre>";
print_r($dateArr);

Error: User Rate Limit Exceeded

Array
(
    [0] => 2010-01-03
    [1] => 2010-01-10
    [2] => 2010-01-17
    [3] => 2010-01-24
    [4] => 2010-01-31
    [5] => 2010-02-07

     ................
     ................
     ................

    [47] => 2010-11-28
    [48] => 2010-12-05
    [49] => 2010-12-12
    [50] => 2010-12-19
    [51] => 2010-12-26
)
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
Error: User Rate Limit Exceeded
0

Error: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit ExceededError: User Rate Limit Exceeded

11

Error: User Rate Limit Exceeded

3

Error: User Rate Limit Exceeded

function getDateForSpecificDayBetweenDates($start, $end, $weekday = 0){

$weekdays="Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday";

$arr_weekdays=split(",", $weekdays);
$weekday = $arr_weekdays[$weekday];
if(!$weekday)
    die("Invalid Weekday!");

$start= strtotime("+0 day", strtotime($start) );
$end= strtotime($end);

$dateArr = array();
$friday = strtotime($weekday, $start);
while($friday <= $end)
{
    $dateArr[] = date("Y-m-d", $friday);
    $friday = strtotime("+1 weeks", $friday);
}
$dateArr[] = date("Y-m-d", $friday);

return $dateArr;
}

Error: User Rate Limit Exceeded

$dateArr = getDateForSpecificDayBetweenDates("Today", "+1 year", 0); // 0 Sun, 1 Mon, etc.

$startError: User Rate Limit Exceeded$endError: User Rate Limit Exceededstrtotime()Error: User Rate Limit Exceeded

Похожие вопросы