php计算当前时间到下个月的剩余天数
php计算当前时间到下个月的剩余天数
//当前时间距离下个月还有多少天
function less_day()
{
$month_big = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
//现在的月份
$date_month_old = (int)date("m",time());
//下个月的月份
$date_month_new = $date_month_old + 1;
//下个月1号的时间戳
$date_time_new = strtotime("1 ".$month_big[$date_month_new-1]." ".date("Y",time()));
//今天的时间戳
$date_time_old = strtotime(date("d",time())." ".$month_big[$date_month_old-1]." ".date("Y",time()));
//距下月剩余时间
$time_new = ($date_time_new - $date_time_old)/24/60/60-1;
return $time_new;
}
header("Content-type: text/html; charset=utf-8");
echo "今天是:".date("Y-m-d",time())."<br/>";
echo "距离下个月还有:".less_day()."天";
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。