Created
June 2, 2012 16:11
-
-
Save zhangguiqiang/2858992 to your computer and use it in GitHub Desktop.
PHP:time_aweek(获取指定日期所在周的开始和结束日期)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aweek($gdate = "", $first = 0){ | |
if(!$gdate) $gdate = date("Y-m-d"); | |
$w = date("w", strtotime($gdate)); | |
$dn = $w ? $w - $first : 6; | |
$st = date("Y-m-d", strtotime("$gdate -".$dn." days")); | |
$en = date("Y-m-d", strtotime("$st +6 days")); | |
return array($st, $en); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function aweek($gdate = "", $first = 0){ | |
if(!$gdate) $gdate = date("Y-m-d"); | |
$w = date("w", strtotime($gdate)); | |
$dn = $w ? $w - $first : 6; | |
$st = date("Y-m-d", strtotime("$gdate -".$dn." days")); | |
$en = date("Y-m-d", strtotime("$st +6 days")); | |
return array($st, $en); | |
} | |
#example | |
#$w = aweek('2011-05-11'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment