jthurstenson Posted October 7, 2008 Share Posted October 7, 2008 I am working on a simple form to be used on our intranet site. The purpose is to request/reserve a vehicle from our automotive dept. I need to check the "DateNeeded" variable agains the "ReturnDate" variable to make sure DateNeeded is before ReturnDate, and return an error if it is not. Thanks in advance. Link to comment https://forums.phpfreaks.com/topic/127402-simple-datetime-check-for-a-form/ Share on other sites More sharing options...
DjMikeS Posted October 7, 2008 Share Posted October 7, 2008 I don't have the full code, but what you should do. convert the returndate into a unix timestamp with http://nl2.php.net/maketime do the same for dateneeded and compare the two. This will allow you to also work with hours of you want to. Link to comment https://forums.phpfreaks.com/topic/127402-simple-datetime-check-for-a-form/#findComment-659009 Share on other sites More sharing options...
jthurstenson Posted October 7, 2008 Author Share Posted October 7, 2008 Thanks for the help. I will play with that and RE with the results. Link to comment https://forums.phpfreaks.com/topic/127402-simple-datetime-check-for-a-form/#findComment-659010 Share on other sites More sharing options...
Brandon Jaeger Posted October 7, 2008 Share Posted October 7, 2008 function is_due($date_needed, $date_return) { $needed = explode('/', $date_needed); $return = explode('/', $date_return); $DateNeeded = mktime(0, 0, 0, $needed[0], $needed[1], $needed[2]); $ReturnDate = mktime(0, 0, 0, $return[0], $return[1], $return[2]); if($DateNeeded < $ReturnDate) return true; return false; } // Example usage: if(is_due('10/7/2008', '10/6/2008')) echo 'due'; else echo 'not due'; Need help, ask Link to comment https://forums.phpfreaks.com/topic/127402-simple-datetime-check-for-a-form/#findComment-659024 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.