$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."秒";