当前位置:网站首页>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');
边栏推荐
- [daily training] 535 Encryption and decryption of tinyurl
- How to use an oak camera as a webcam?
- 数据分析基础--预测模型
- jdbc认识上手
- MySQL 企業級開發規範
- 深度学习---三好学生各成绩所占权重问题(2)
- MySQL Enterprise Development Specification
- Tag filtering and SQL filtering of rocketmq
- Anaconda installs and configures jupyter notebook remote
- 2. how to install MySQL database in Galaxy Kirin offline mode
猜你喜欢
![[Nanjing University] information sharing of the first and second postgraduate entrance examinations](/img/0d/a6392e6b92bb689e90c038ffac9dd8.jpg)
[Nanjing University] information sharing of the first and second postgraduate entrance examinations

Shandong University project training (VII) add navigation bar to select city

Anfulai embedded weekly report no. 271: June 20, 2022 to June 26, 2022

UnrealEngine插件中使用protobuf 链接mysql

The table ‘table_name‘ is full 异常排查及解决方案

Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)

Machine learning 7-Support vector machine

Adobe Premiere foundation - opacity (matte) (11)

C Primer Plus 第12章_存储类别、链接和内存管理_代码和练习题

The strategy of convertible bonds -- - (cake sharing, premium, forced redemption, downward revision, double low)
随机推荐
Selenium WebDriver的高级特性
garbage collector
js将秒转换成“2h30min50s”的格式
RocketMQ的tag过滤和sql过滤
Anaconda安装并配置jupyter notebook远程
Adobe Premiere Basics - common video effects (cropping, black and white, clip speed, mirroring, lens halo) (XV)
Svg circle drawing path animation
curl下载示例
Chapter 02_ MySQL data directory
源码安装MAVROS
Adobe Premiere foundation - opacity (matte) (11)
面试题 10.10. 数字流的秩
Shandong University project training (VII) add navigation bar to select city
Goldfish rhca memoirs: do447 build advanced job workflow -- create workflow job template and start workflow job
Notes on spintronics - zhangshufeng
Error building SqlSession问题
JS text particle dynamic background
Apache inlong million billion level data stream processing
BeanUtils属性复制的用法
Sd6.23 summary of intensive training