0

I have three dates to compare:

$pDate = date("d/m/Y G:i A");
$lDate = new DateTime('last wednesday G:i A');
$cDate = new DateTime('next tuesday G:i A');

If $pDate is in between $lDate and $cDate then mysql table field is updated yes

i.e. the 9th is in between the 8th and 14th

If $pDate is less than equal to $lDate then MySQL table field is updated no

$pDate cannot be more than $cDate

How would I write a elseif statement for the above? i.e.

elseif ( .... ) {
    mysql_query("UPDATE ... SET ... WHERE ...");
}
halfer
  • 19,824
  • 17
  • 99
  • 186
methuselah
  • 12,766
  • 47
  • 165
  • 315

2 Answers2

1
if ($lDate < $pDate && $cDate > $pDate) {
 // do table insert or update here
} else {
 // date is not in desired range.
}

php date compares like a number.

Heres a post you should look at. How to Compare Dates in php?

Community
  • 1
  • 1
Gauthier
  • 1,251
  • 10
  • 25
0

you can try IF ELSE condition in the MySQL query. try this to solve your problem, let me know if you dont.

Chandresh M
  • 3,808
  • 1
  • 24
  • 48