【PHP原生】两个日期间的相关计算

1、枚举两个日期中间的所有日期

<?php
function prDates($start, $end)
{
    $dt_start = strtotime($start);
    $dt_end = strtotime($end);
    $temp = [];
    while ($dt_start <= $dt_end) {
        $re = date('Y-m-d', $dt_start);
        $temp[] = $re;
        $dt_start = strtotime('+1 day', $dt_start);
    }
    return $temp;
    // 返回data型数据
}

2、获取两个日期之间的天数

<?php
function countData($Date_1, $Date_2)
{
    $d1 = strtotime($Date_1);
    $d2 = strtotime($Date_2);
    $Days = ($d1 - $d2) / 3600 / 24;
    return $Days;
    // 返回int型数据
}

--------------------------------------------------------------------
承接网站开发、小程序开发、app开发、商城开发、公众号开发。
百度SEO排名、百度搜索霸屏、软文代写等业务。
联系QQ:2779459018     联系微信:qianxia39

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值