phpretard Posted July 3, 2010 Share Posted July 3, 2010 This work for adding 18 years but not subtracting... function select_yr(){ // WORKS $stopy = (int)date('Y') + 18; for($y = date('Y'); $y < $stopy; $y++){ echo '<option value="'.$y.'">'.$y.'</option>'; } } function select_yr(){ // DOES NOT WORK $stopy = (int)date('Y') - 18; for($y = date('Y'); $y < $stopy; $y++){ echo '<option value="'.$y.'">'.$y.'</option>'; } } Any help? Thank you Link to comment https://forums.phpfreaks.com/topic/206621-date-help-please/ Share on other sites More sharing options...
phpretard Posted July 3, 2010 Author Share Posted July 3, 2010 function select_yr(){//works $stopy=date('Y')+1; for($y = date('Y')-18; $y < $stopy; $y++){ echo '<option value="'.$y.'">'.$y.'</option>'; } } Link to comment https://forums.phpfreaks.com/topic/206621-date-help-please/#findComment-1080639 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.