Daleeburg Posted March 22, 2007 Share Posted March 22, 2007 I am attempting to make a way so that my users have to be 13 years old in order to register, is there any easy way to do this, or am i coding 3 if else statements to compare current day and current month, and current year to the posted y/m/d? ~D Quote Link to comment https://forums.phpfreaks.com/topic/43861-solved-comparing-dates/ Share on other sites More sharing options...
Orio Posted March 22, 2007 Share Posted March 22, 2007 I think this should work <?php //$date must be in month/day/year format if(strtotime($date) > strtotime("-13 years")) echo "You are older than 13"; else echo "You are not older than 13"; ?> Orio. Quote Link to comment https://forums.phpfreaks.com/topic/43861-solved-comparing-dates/#findComment-212926 Share on other sites More sharing options...
Daleeburg Posted March 22, 2007 Author Share Posted March 22, 2007 the input needs to be in MM/DD/YYYY or can it be M/D/YYYY? ~d Quote Link to comment https://forums.phpfreaks.com/topic/43861-solved-comparing-dates/#findComment-212933 Share on other sites More sharing options...
Orio Posted March 22, 2007 Share Posted March 22, 2007 It's the same... Orio. Quote Link to comment https://forums.phpfreaks.com/topic/43861-solved-comparing-dates/#findComment-212934 Share on other sites More sharing options...
Daleeburg Posted March 22, 2007 Author Share Posted March 22, 2007 note to self, smaller dates are older, so all i had to to was flip around the great then to a less then, and now it works. thanks, ~D Quote Link to comment https://forums.phpfreaks.com/topic/43861-solved-comparing-dates/#findComment-212954 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.