christa Posted December 6, 2008 Share Posted December 6, 2008 Hi all i have two input date: From (yyyy-mm-dd) and To (yyyy-mm-dd). I have to make sure that the interval between the dates does not exceed 10 days: how can i do? thanks Link to comment https://forums.phpfreaks.com/topic/135771-check-date-interval/ Share on other sites More sharing options...
fanfavorite Posted December 6, 2008 Share Posted December 6, 2008 $days = (strtotime($To) - strtotime($From)) / 86400 + 1; if ($days > 10) { echo "you exceeded 10 days"; } Link to comment https://forums.phpfreaks.com/topic/135771-check-date-interval/#findComment-707454 Share on other sites More sharing options...
dclamp Posted December 6, 2008 Share Posted December 6, 2008 there is also this user function: http://us.php.net/manual/en/function.date.php#86907 Link to comment https://forums.phpfreaks.com/topic/135771-check-date-interval/#findComment-707456 Share on other sites More sharing options...
OldWolf Posted December 6, 2008 Share Posted December 6, 2008 I believe the above might be off... "to" should be larger than "from" when turning it into a time stamp. if ((strtotime($to) - strtotime($from)) > 864000) { echo "EPIC FAIL!"; } Link to comment https://forums.phpfreaks.com/topic/135771-check-date-interval/#findComment-707457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.