HuyPV
Tuesday, January 10, 2012
Mon Tue Wed Thu Fri Sat Sun
$str = date('Y-m-d');
$iStr = strtotime($str);
$n = date('N', $iStr);#Mon = 1, Sun = 7
$d1 = $n - 1; $d2 = 7 - $n;
# monday in week
$mon = date('Y-m-d', strtotime("-$d1 days", $iStr));
# sunday in week
$sun = date('Y-m-d', strtotime("+$d2 days", $iStr));
var_dump($mon, $sun);
Title:
PHP get first and last day of week
Description:
Mon Tue Wed Thu Fri Sat Sun $str = date('Y-m-d'); $iStr = strtotime($str); $n = date('N', $iStr);#Mon = 1, Sun = ...
...
Rating:
4