php - Broken switch statement -
ive been searching , staring hours , i'm @ loss. have following code when august date passed through switch (as aug) statement keeps returning 0 value instead of 8. echo results below code block. ideas might going wrong? seemed work july , broke on august 1st.
$when=date("y-m-d"); $created=date("ymd"); $date=explode('-',$emprow->hire_date); echo "<br>hire date ";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 ";print_r($date);echo "<br>"; $startdate=sprintf("%04d%02d%02d",$date[2],$misc->getmonthnum($date[1]),$date[0]);
which results in following:
hire date array ( [0] => 05 [1] => aug [2] => 2013 )
hire date array ( [0] => 05 [1] => 0 [2] => 2013 )
startdate date 20130005
i verified put in comments.
08 non-existant octal number. use "08" or 8
you can pad zeros when you're ready output it.
here's illustration of what's going on in php original code:
$date[1]=08; echo $date[1]; echo ' | '; $date[1]=010; echo $date[1];
output:
0 | 8
Comments
Post a Comment