phpretard Posted December 13, 2010 Share Posted December 13, 2010 Why does this work: $dateAllowedSelect = date('Y') -18; But this doesn't: $dateAllowedSelect = date('Y') +5; I nee to get the current year plus 2010 - 2015 in a select box. Thank you. Link to comment https://forums.phpfreaks.com/topic/221496-year-plus-five/ Share on other sites More sharing options...
radar Posted December 13, 2010 Share Posted December 13, 2010 http://www.w3schools.com/PHP/php_date.asp that'll give ya the gist on how to do it.. Link to comment https://forums.phpfreaks.com/topic/221496-year-plus-five/#findComment-1146577 Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2010 Share Posted December 13, 2010 Since $dateAllowedSelect = date('Y') +5; produces the expected value of 2015, you apparently have some problem in your code that is using that value. Link to comment https://forums.phpfreaks.com/topic/221496-year-plus-five/#findComment-1146579 Share on other sites More sharing options...
phpretard Posted December 13, 2010 Author Share Posted December 13, 2010 This shows the value from 2010 to 1992: <?php $dateAllowedSelect = date('Y') - 18; $myCalendar = new tc_calendar("DOB", true); $myCalendar->setPicture("images/iconCalendar.gif"); if (isset($_POST['DOB'])){ $expDOB = explode("-", $_POST['DOB']); $myCalendar->setDate($expDOB[2], $expDOB[1], $expDOB[0]); }else{ $myCalendar->setDate(date('d'), date('m'), date('Y')); } $myCalendar->setPath("./"); $myCalendar->setYearSelect($dateAllowedSelect, date('Y')); $myCalendar->dateAllow('$dateAllowedSelect-01-01', date('Y-m-d')); $myCalendar->writeScript(); ?> This only shows 2010: <?php $dateAllowedSelect = date('Y') + 3; $myCalendar = new tc_calendar("DOP", true); $myCalendar->setPicture("images/iconCalendar.gif"); if (isset($_POST['DOP'])){ $expDOP = explode("-", $_POST['DOP']); $myCalendar->setDate($expDOP[2], $expDOP[1], $expDOP[0]); }else{ $myCalendar->setDate(date('d'), date('m'), $dateAllowedSelect); } $myCalendar->setPath("./"); $myCalendar->setYearSelect($dateAllowedSelect, date('Y')); $myCalendar->dateAllow('$dateAllowedSelect-01-01', date('Y-m-d')); $myCalendar->writeScript(); ?> I can't figure the problem. Link to comment https://forums.phpfreaks.com/topic/221496-year-plus-five/#findComment-1146585 Share on other sites More sharing options...
PFMaBiSmAd Posted December 13, 2010 Share Posted December 13, 2010 Your setYearSelect method or dateAllow method probably expects the min value to be less than the max value. Link to comment https://forums.phpfreaks.com/topic/221496-year-plus-five/#findComment-1146588 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.