strtotime 方法返回结果跟预期不符
异常 demo
$yesterday = '2023-10-31';
$last_m = date('Y-m', strtotime('last month',strtotime($yesterday)));
// 期望 $last_m = '2023-09' 实际 $last_m = '2023-10'
$this_m = date('Y-m', strtotime($yesterday));
正常 demo
$yesterday = '2023-10-31';
$this_m = date('Y-m', strtotime($yesterday));
$last_m = date('Y-m', strtotime('last month', strtotime($this_m)));
疑问
是环境配置问题?还是 strtotime 本身的问题?
推荐文章: