最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP获取本周第一天和最后一天
时间:2022-11-14 23:01:03 编辑:袖梨 来源:一聚教程网
//本周的第一天和最后一天
| 代码如下 | 复制代码 |
| $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]; } |
|
相关文章
- qq邮箱网页版扫码快捷登录-qq邮箱网页版文件中转站直达 02-12
- 星火英语估分入口-星火英语估分器使用指南 02-12
- 樱花动漫APP下载安装最新版本-樱花动漫官方正版APP下载入口 02-12
- 微博网页版入口-微博官网最新在线浏览地址 02-12
- poipiku官网登录入口2026-poipiku官方最新登录地址首页 02-12
- byrut游戏网站怎么进-byrut俄罗斯游戏网站进入教程 02-12