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
https://forums.phpfreaks.com/topic/14450-compare-dates/
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
https://forums.phpfreaks.com/topic/14450-compare-dates/#findComment-58451
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.