Jump to content

Compare Dates


glenelkins

Recommended Posts

Hi

So i take 3 dates from a form. These are then run through a save script into the database. here is the code to take one of the dates from the form and convert to a unix stamp (the other 2 date boxes work the same):

[code]
$temp_wd = explode("-",$_POST['date']);
$wed = mktime(0,0,0,$temp_wd[1],$temp_wd[0],$temp_wd[2]);
$weddingdate = date("Y-m-d",$wed);
[/code]

now the next date comes as vars; $temp_gd, $group and $groupdate. How can I compare these two dates in an if statement? I want to test if $weddingdate > $groupdate.
Link to comment
Share on other sites

Here is the code, its does not work. Its supposed to return with header() but it carries on the code

[code]
$temp_wd = explode("-",$_POST['date']);
$wed = mktime(0,0,0,$temp_wd[1],$temp_wd[0],$temp_wd[2]);
$weddingdate = date("Y-m-d",$wed);

$temp_gd = explode("-",$_POST['groupdate']);
$group = mktime(0,0,0,$temp_gd[1],$temp_gd[0],$temp_gd[2]);
$groupdate = date("Y-m-d",$group);

//$groupremind = $_POST['groupremind'];

if ($_POST['reminderdate'] != "") {
  $temp_grd = explode ("-",$_POST['reminderdate']);
  $remind = mktime(0,0,0,$temp_grd[1],$temp_grd[0],$temp_grd[2]);
  $groupreminddate = date("Y-m-d",$remind);
} else {
  $groupreminddate = "00-00-0000";
}

if ($weddingdate < $groupdate) {
header ("Location: index.php?page=2&message=Wedding Date Is Smaller Than The Group Tell Date");
}
[/code]
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.

Guest
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.