2010-05-09 3 views

답변

1

먼저 타임 스탬프 (strtotime, mktime, 뭐든지)로 변환하십시오. 그래서 $ tm은 00:00:00의 타임 스탬프라고 가정합니다.

$w = date("w", $tm); 
echo(date("Y-D-m", $tm - (86400 * $w))); 
echo(date("Y-D-m", $tm + 86400 * (6 - $w))); 
2

(5.2 이상 PHP)와 DateTime :

function weekBorders($date) { 
    $borders = array(); 
    $borders['first'] = new DateTime($date->format('Y-m-d') .' - '. $date->format('w') .' days'); 
    $borders['last'] = new DateTime($date->format('Y-m-d') .' + '. (6 - $date->format('w')) .' days'); 
    return $borders; 
} 
관련 문제