Jump to content

Unix timestamp comparison

Go to solution Solved by Barand,

Recommended Posts

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";


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.