felito Posted June 22, 2011 Share Posted June 22, 2011 hi how can i get only the years, and check them? what i am trying: $year = strtok($date, '-'); //problem here - only get the first year of array $date = array ("1979-06-13", "2979-06-13"); foreach ($date as $key) { if (2000 > $year) { echo ('true'); } else echo ("error"); } but i get true, true, so the second date is not working... thanks Quote Link to comment https://forums.phpfreaks.com/topic/240050-problem-with-date/ Share on other sites More sharing options...
felito Posted June 22, 2011 Author Share Posted June 22, 2011 foreach ($date as $key) { $year = strtok($key, '-'); if (3000 > $year) { echo ('true'); } else echo ("error"); } solved, thanks Quote Link to comment https://forums.phpfreaks.com/topic/240050-problem-with-date/#findComment-1233089 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.