最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP獲取本周第一天和最后一天示例代碼

 更新時間:2014年02月24日 11:41:14   作者:  
這篇文章主要介紹了PHP獲取本周第一天和最后一天的方法,需要的朋友可以參考下
//本周的第一天和最后一天
復制代碼 代碼如下:

$date=new DateTime();
$date->modify('this week');
$first_day_of_week=$date->format('Y-m-d');
$date->modify('this week +6 days');
$end_day_of_week=$date->format('Y-m-d');

經過測試modity不知道是用做什么了,于時找了另兩個例子
復制代碼 代碼如下:

//這個星期的星期一
// @$timestamp ,某個星期的某一個時間戳,默認為當前時間
// @is_return_timestamp ,是否返回時間戳,否則返回時間格式
function this_monday($timestamp=0,$is_return_timestamp=true){
static $cache ;
$id = $timestamp.$is_return_timestamp;
if(!isset($cache[$id])){
if(!$timestamp) $timestamp = time();
$monday_date = date('Y-m-d', $timestamp-86400*date('w',$timestamp)+(date('w',$timestamp)>0?86400:-/*6*86400*/518400));
if($is_return_timestamp){
$cache[$id] = strtotime($monday_date);
}else{
$cache[$id] = $monday_date;
}
}
return $cache[$id];
}

//這個星期的星期天
復制代碼 代碼如下:

// @$timestamp ,某個星期的某一個時間戳,默認為當前時間
// @is_return_timestamp ,是否返回時間戳,否則返回時間格式
function this_sunday($timestamp=0,$is_return_timestamp=true){
static $cache ;
$id = $timestamp.$is_return_timestamp;
if(!isset($cache[$id])){
if(!$timestamp) $timestamp = time();
$sunday = this_monday($timestamp) + /*6*86400*/518400;
if($is_return_timestamp){
$cache[$id] = $sunday;
}else{
$cache[$id] = date('Y-m-d',$sunday);
}
}
return $cache[$id];
}

相關文章

最新評論

潞城市| 白玉县| 元谋县| 绥德县| 崇阳县| 于都县| 分宜县| 惠水县| 灵丘县| 孙吴县| 龙山县| 济阳县| 富民县| 奉节县| 灌阳县| 襄城县| 东明县| 通山县| 肥西县| 姜堰市| 定襄县| 万山特区| 麟游县| 哈密市| 昔阳县| 四子王旗| 密云县| 松桃| 邢台县| 湘西| 墨竹工卡县| 永安市| 鹿邑县| 东乌珠穆沁旗| 新乡县| 太谷县| 铜梁县| 山东| 孝昌县| 长阳| 衡东县|