phpretard Posted December 14, 2010 Share Posted December 14, 2010 I am trying to compare values and if the month is not of 2 digits then the comparison goes wrong. Here is some hacked crap that doesn't work. if (strlen($_POST['m'] <= 1)){$month = "0".$_POST['m'];}else{$month = $_POST['m'];} if (strlen($_POST['d'] <= 1)){$day = "0".$_POST['d'];}else{$day = $_POST['d'];} <form> function GetDays(){ $Listd = '<select name="d">'; if (isset($_POST['d'])){$Listd .='<option value="'.$_POST['d'].'">'.$_POST['d'].'</option>';} for ($x = 1; $x <= date('d'); $x++) $Listd .= '<option value="'.$x.'">'.$x.'</option>'; $Listd .= '</select>'; return $Listd; } function GetMonths(){ $Listm = '<select name="m">'; if (isset($_POST['m'])){$Listm .='<option value="'.$_POST['m'].'">'.$_POST['m'].'</option>';} for ($x = 1; $x <= date('m'); $x++) $Listm .= '<option value="'.$x.'">'.$x.'</option>'; $Listm .= '</select>'; return $Listm; } Here is what I am comparing: Now: 201012141292327875 Submitted: 201110101292353200 // 2 digit month/day Now: 201012141292327984 Submitted: 2011991292353200 // not 2 digits month/day 2 hours is enough for me...can someone shed some light on this for me please? Link to comment https://forums.phpfreaks.com/topic/221615-the-zero-in-the-day-and-month-will-not-post/ Share on other sites More sharing options...
MMDE Posted December 14, 2010 Share Posted December 14, 2010 may it be because it handles it as a number and not as a string? =o oh and if that is the case, use this function to solve the problem: http://php.net/manual/en/function.number-format.php Link to comment https://forums.phpfreaks.com/topic/221615-the-zero-in-the-day-and-month-will-not-post/#findComment-1147127 Share on other sites More sharing options...
phpretard Posted December 14, 2010 Author Share Posted December 14, 2010 Worked like a charm! Thank you. Link to comment https://forums.phpfreaks.com/topic/221615-the-zero-in-the-day-and-month-will-not-post/#findComment-1147131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.