2010-05-09 7 views

Répondre

1

D'abord le convertir en un horodatage (strtotime, mktime, peu importe). Donc je suppose que $ tm est un horodatage à 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

Avec DateTime (PHP 5.2+):

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; 
} 
Questions connexes