我一直在寻找和盯着几个小时,我很茫然。我有以下代码,当通过 switch(作为 AUG)语句传递八月日期时,它会不断返回值的 0 而不是 8。回显结果位于代码块下方。有什么想法可能会出错吗?它似乎在 7 月运行良好,并在 8 月 1 日中断。
$when=date("Y-m-d");
$created=date("Ymd");
$date=explode('-',$emprow->HIRE_DATE);
echo "<br>hire date is ";print_r($date);echo "<br>";
switch ($date[1])
{
case "JAN":
$date[1]=01;
break;
case "FEB":
$date[1]=02;
break;
case "MAR":
$date[1]=03;
break;
case "APR":
$date[1]=04;
break;
case "MAY":
$date[1]=05;
break;
case "JUN":
$date[1]=06;
break;
case "JUL":
$date[1]=07;
break;
case "AUG":
$date[1]=08;
break;
case "SEP":
$date[1]=09;
break;
case "OCT":
$date[1]=10;
break;
case "NOV":
$date[1]=11;
break;
case "DEC":
case "Dec":
$date[1]=12;
break;
}
echo "<br>hire date is ";print_r($date);echo "<br>";
$startdate=sprintf("%04d%02d%02d",$date[2],$misc->getmonthnum($date[1]),$date[0]);
结果如下:
雇用日期是Array ( [0] => 05 [1] => AUG [2] => 2013 )
雇用日期是Array ( [0] => 05 [1] => 0 [2] => 2013 )
开始日期是 20130005