0
我得到这个代码日期转换mktime返回错误的日期
<?php
function dateFunc($month)
{
setlocale(LC_TIME, 'spanish');
$monthSub = date('m',strtotime($month));
$name=strftime("%B",mktime(0,0,0,$monthSub,1,2000));
$name = $name.' '.date('Y', strtotime($month));
return strtoupper($name);
}
$output ="";
$output.=
dateFunc(date('Y-m', strtotime('-1 month'))).'<br>
'.dateFunc(date('Y-m', strtotime('-2 month'))).'<br>
'.dateFunc(date('Y-m', strtotime('-3 month'))).'<br>
'.dateFunc(date('Y-m', strtotime('-4 month'))).'<br>
'.dateFunc(date('Y-m', strtotime('-5 month'))).'<br>';
echo $output;
?>
输出是
JULIO 2017
MAYO 2017
MAYO 2017
MARZO 2017
MARZO 2017
I'm期待这个输出
JULIO 2017
JUNIO 2017
MAYO 2017
ABRIL 2017
MARZO 2017
有一天我读到这个问题
,冲突发生在30天的月份,mktime()
需要另一个参数,但我不记得如何解决它。
建议请...
@阿尔贝托 - siurob请接受帮你答案。 – Vladislav