【发布时间】:2020-03-31 15:51:21
【问题描述】:
我有一个如下所示的 php 代码,我试图在其中检索下个月的最后一天。
<?php
date_default_timezone_set('America/Toronto');
echo date('l jS \of F Y h:i:s A');
$next_month_last_day = date('t', strtotime('next month')); // last day of the next month
print_r("\n");
print_r($next_month_last_day); // Line A
?>
问题陈述:
我想知道我在上面的 php 代码中犯了什么错误,因为 A 行 处的代码打印 31。它应该打印 30,因为最后一个 下个月(四月)是 30 号。
【问题讨论】:
-
@mech 我在上面的代码中做错了什么?
-
@flash 查看我的链接:“PHP date() 和 strtotime() 在 31 日返回错误月份”