mflevie44 Posted September 29, 2013 Share Posted September 29, 2013 Can any one tell me what's wrong with this code? it's just keep giving me this message "Pick up Date atleast 24hrs after the current Date"; $pDate = $_GET['txtPDate']; $pTime = $_GET['txtPTime']; $dateArray = explode('-',$pDate); $timeArray = explode('.',$pTime); $hours = (int)$timeArray[0]; $minutes = (int)$timeArray[1]; $day = (int)$dateArray[0]; $month = (int)$dateArray[1]; $year = (int)$dateArray[2]; $userPTimes = mktime(date($hours),date($minutes),0,date($month), date($day), date($year)); $userCurrentTime = mktime(0, 0, 0, date($day), date($month), date($year)); $userupperlimit = mktime(date(7), date(30), date(0), date($day), date($month), date($year)); $userlowerlimit = mktime(date(20), date(30), date(0), date($day), date($month), date($year)); $dayafter = mktime(0, 0, 0, date($day +1), date($month), date($year)); // I wanted $dayafter to 24 hours after the $pdate if($userCurrentTime < $dayafter) { echo "Pick up Date atleast 24hrs after the current Date"; } else if(!($userPTimes >= $userupperlimit) || !($userPTimes <= $userlowerlimit )) { echo "Pick up Time should be between 7.30 - 20.30"; } Quote Link to comment https://forums.phpfreaks.com/topic/282521-unix-timestamp-comparison/ Share on other sites More sharing options...
Solution Barand Posted September 29, 2013 Solution Share Posted September 29, 2013 The date() function returns a formatted date string from a unix timestamp. mktime() requires six integers in the order (hr, min, sec, month, day, year) if $ptime is a unix timestamp, the next day can be found with $next = strtotime('+1 days', $ptime); Quote Link to comment https://forums.phpfreaks.com/topic/282521-unix-timestamp-comparison/#findComment-1451663 Share on other sites More sharing options...
mflevie44 Posted September 29, 2013 Author Share Posted September 29, 2013 Thanks mate it solved the problem..... Quote Link to comment https://forums.phpfreaks.com/topic/282521-unix-timestamp-comparison/#findComment-1451666 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.