dylandcor Posted July 7, 2009 Share Posted July 7, 2009 I use this in a registration form so that the form remembers the value if there is an error. When it passes a certain time, $closed_oakdale, I would like one of the options to disappear. The form values don't seem to switch no matter what time I put. It always seems that $now is always less than $closed_oakdale. I can't seem to figure out what is wrong, but I'm sure it's simple. Sorry for my lack of knowledge. Any help would be greatly appreciated! <?php $now= strtotime('now'); $closed_oakdale= strtotime('July 06, 2009 23:02:15'); if($now < $closed_oakdale) { $arr = array('Select a Campus', 'Oakdale', 'Bridgeville'); } if($now > $closed_oakdale){ $arr = array('Select a Campus', 'Bridgeville'); } for($i2 = 0; $i2 < count($arr); $i2++) { if(isset($campus)){ $selected = ($arr[$i2] == $campus) ? 'selected="selected"' : ''; }else{ $selected = ($arr[$i2] == $arr[0]) ? 'selected="selected"' : ''; } echo "<option value=\"{$arr[$i2]}\" {$selected}>{$arr[$i2]}</option>\n"; } ?> Link to comment https://forums.phpfreaks.com/topic/165018-solved-comparing-times/ Share on other sites More sharing options...
dylandcor Posted July 7, 2009 Author Share Posted July 7, 2009 I solved it myself. I found the difference and checked whether it was positive or negative. Link to comment https://forums.phpfreaks.com/topic/165018-solved-comparing-times/#findComment-870397 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.