php倒计时 时分秒 (每个月1号到最后一天)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/adminyan/article/details/79257291
$startDate = date('Y-m-01', strtotime(date("Y-m-d")));
        $endDate = date('Y-m-d', strtotime("$startDate +1 month -1 day"));
        // 将日期转换为Unix时间戳
        $endDate=$endDate." 23:59:59";
        $startDateStr = strtotime($startDate);
        $endtDateStr = strtotime($endDate);
        $total = $endtDateStr-$startDateStr;

        $now = strtotime(date('Y-m-d H:i:s'));
        $remain = $endtDateStr-$now;
        $day= intval($remain/86400);;//天
        $remains = $remain%86400;
        $hour = intval($remains/3600);
        //计算分钟数
        $remain1 = $remain%3600;
        $minute = intval($remain1/60);
        //计算秒数
        $second = $remain%60;
        echo $day."天".$hour.'小时'.$minute.'分'.$second."秒";

展开阅读全文

没有更多推荐了,返回首页