惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 工具人Kim哥

mysql数据库备份命令大全 Vue获取url网址参数的两种方法 在vscode下编译vue神坑40% building 过不去 vue元素对齐方式 一个身高体重测量工具(BMI测量工具) HTML代码格式化实现方式 一个不错的常用小工具站点 Fiddler使用 不错的SDL源码分析 unity3d中获得物体的size PPT文化 Unity消息 Unity3D中的UnitySendMessage方法的使用 Android性能优化之渲染 问题记录 VS2012项目中使用CocoStudio相关文件的设置 国际金融基础知识 Nutch 安装文档 sed linux 命令
PHP获取本周的每一天的时间
工具人Kim哥 · 2023-10-13 · via 博客园 - 工具人Kim哥

1.PHP获取未来一周的时间

public function getWeek()
{
    for($i=0;$i<7;$i++)
    {
        $arr[$i]=date('Y-m-d',strtotime(date('Y-m-d').'-'.$i.'day'));
    }

    return json($arr);
}    

2.PHP获取本周每一天的时间

public function getDay()
{
$timestr = time(); //当前时间戳
$now_day = date('w',$timestr); //当前是周几

//获取周一
$monday_str = $timestr - ($now_day-1)*60*60*24;
$monday = date('Y-m-d', $monday_str);

//获取周日
$sunday_str = $timestr + (7-$now_day)*60*60*24;
$sunday = date('Y-m-d', $sunday_str);

for($i=0;$i<7;$i++)
{
$arr[$i]=date('Y-m-d',strtotime($monday.'+'.$i.'day'));
}
return json($arr);
// echo "星期一: $monday\n";
// echo "星期天: $sunday\n";
}

效果:

["2023-11-11","2023-11-12","2023-11-13","2023-11-14","2023-11-15","2023-11-16","2023-11-17"]