phpretard Posted July 27, 2008 Share Posted July 27, 2008 I am trying to make sure someone post a date at least greater than today. if (!ereg ("([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})", $LicEXP)) All I can figure is the format? Any help today? Link to comment https://forums.phpfreaks.com/topic/116875-date-validation/ Share on other sites More sharing options...
Attila Posted July 27, 2008 Share Posted July 27, 2008 This can work depending on how you have them input the day month and year. If you do them as 3 different boxes then you can usesomething like the below. Obviously you will have to do some error checking to make sure you do not go from the 31st to the 1st. If so then compare months and same for years. It could be a quick function. <? $today = date("j, m, y"); $daytoday = date("j"); echo "$today"; echo "<br>"; echo "$daytoday"; echo "<br>"; $tomorow = date("j")+1; echo "$tomorow"; echo "<br>"; if ($daytoday > $tomorow) { echo "You are in the future"; } else { echo "You are in the past"; } ?> Link to comment https://forums.phpfreaks.com/topic/116875-date-validation/#findComment-601026 Share on other sites More sharing options...
GingerRobot Posted July 27, 2008 Share Posted July 27, 2008 Just use strtotime()/mktime(). Then check to see if the returned integer is greater than time(). Link to comment https://forums.phpfreaks.com/topic/116875-date-validation/#findComment-601095 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.