当前位置:网站首页>PHP 输出两个指定日期之间的所有日期
PHP 输出两个指定日期之间的所有日期
2022-06-29 18:29:00 【杭杭爸爸】
两个方法,一个是包含首尾,一个不包含
/**
* Notes: 两个指定日期之间的所有日期(不带开始时间,结束时间)
* param $start 开始时间
* param $end 结束时间
* return array
*/
function Dates($start, $end)
{
$response = [];
$dt_start = strtotime($start);
$dt_end = strtotime($end);
while ($dt_start < $dt_end) {
$dt_start = strtotime('+1 day', $dt_start);
if ($dt_start != $dt_end) {
array_push($response, date('Y-m-d', $dt_start));
}
}
return $response;
}
/**
* Notes: 两个指定日期之间的所有日期(带开始时间,结束时间)
* param $start 开始时间
* param $end 结束时间
* return array
*/
function Dates1($start, $end)
{
$response = [];
$dt_start = strtotime($start);
$dt_end = strtotime($end);
while ($dt_start <= $dt_end) {
array_push($response, date('Y-m-d', $dt_start));
$dt_start = strtotime('+1 day', $dt_start);
}
return $response;
}
## 调用
//当前时间距离指定时间还差多少天,时,分,秒
$Dates = $this->Dates('2021-11-25', '2021-11-29');
边栏推荐
- 踩坑记:JSON.parse和JSON.stringify
- Amazing pandaverse:meta "borderless, to activate fashion attributes in the new journey of 2.0
- Us judge ruled that the former security director of Uber accused of covering up hacking must face fraud charges
- UnrealEngine插件中使用protobuf 链接mysql
- Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022
- JDBC Codes connexes
- centos 7.5安装mysql 8.0.27----yum
- jdbc_ Related codes
- 移动端测试
- js将秒转换成“2h30min50s”的格式
猜你喜欢

Sword finger offer 34 Path DFS method for binary tree neutralization

markdown知识轻轻来袭
![[how the network is connected] Chapter 3 explores hubs, switches and routers](/img/a9/39f7c474331b7de0bdaf6e59f0d15b.png)
[how the network is connected] Chapter 3 explores hubs, switches and routers

Dragon canvas animation

对强缓存和协商缓存的理解

How to use the low code platform of the Internet of things for service management?

Up to 81.98%! Announcement of undergraduate study rate of more than 100 "double first-class" Universities

Source code installation mavros

sql server备份以及还原的命令操作

These advantages of the Institute are really fragrant! The landing rate is still very high!
随机推荐
防汛救援便携式应急通信系统解决方案
踩坑记:JSON.parse和JSON.stringify
Failed to allocate graph: myriad device is not opened
Apache InLong百万亿级数据流处理
WBF: new method of NMS post filter frame for detection task?
Adobe Premiere foundation - time remapping (10)
Weibo comments on high-performance and high availability architecture design (module 5 of architecture practice camp)
How to use an oak camera as a webcam?
Apache Doris 基本使用总结
保持jupyter notebook在终端关闭时的连接方法
sql server备份以及还原的命令操作
Data-* attribute usage
Page Object与数据驱动测试
Sd6.22 summary of intensive training
2022.6.29-----leetcode.535
报错[warning] Neural network inference was performed on socket ‘RGB’, depth frame is aligned to socket
产品-Axure9(英文版),中继器(Repeater)实现表格内容的增删查改(CRUD)
Error building SqlSession问题
Error building sqlsession problem
The 8th "Internet +" competition - cloud native track invites you to challenge