2011-07-18 2 views
3

이 다음 토요일보기 다음 세 토요일

<?php echo date("l,j M Y", strtotime("next saturday")); ?> 

즉 7월 23일 (토요일)을 보여 2011 년 나는 지난 7 월 2011 그래서

(토) 30 다음 다음 토요일을 보여주고 싶은

+0

질문이 불완전합니다. 이게 무슨 뜻이야? –

+0

* (참고) * http://php.net/manual/en/datetime.formats.relative.php – Gordon

답변

10

, \ 날짜 시간과

strtotime("next saturday + 1 week") 
strtotime("next saturday + 2 weeks") 
... 
+0

물론 '주'를 어디에서나 사용할 수 있습니다. 'strtotime ("다음 토요일 + $ 주 주")' – Naltharial

+0

날짜 ("Y-m-d", strtotime ('토요일 +1 주')) –

0
$next_saturday = strtotime("next saturday"); 
$the_saturday_after_that = strtotime("next saturday", $next_saturday); 

... 등등.

2

PHP 5.2 이상을 사용하면 다음 3 토를 얻을 수 DateTimeDateInterval를 사용할 수 있습니다

예 : 또는

<?php 

$date = new DateTime('next saturday'); 

// Loop 3 times. 
for ($i = 0; $i < 3; $i++) 
{ 
    echo $date->format('Y-m-d') . PHP_EOL; 

    // Add 1 month. 
    $date->add(new DateInterval('P7D')); 
} 
1

예 :

/** 
* Get next three saturday 
* 
* @return \DateTime[] 
*/ 
function getNextThreeSaturday() 
{ 
    $count = 3; 
    $current = new \DateTime('saturday this week'); 

    $results = []; 
    for ($i = 0; $i < $count; $i++) { 
     $results[] = clone $current->modify('next saturday'); 
    } 

    return $results; 
}