Date Comparison PHP - dd / mm / yyyy [duplicate]

1

I'm wanting to do a date comparison in PHP of type: if DataStart & Date = DateTime + 3 days, do such thing. Otherwise, it does nothing. I tried something like this:

if ((1/86400)*(strtotime($_SESSION['buscaReserva']['dataInicio'])-strtotime(date("d/m/Y"))))>=3) {
   // Do something }
else {
   // Do nothing }

The two dates are initially in the format dd / mm / yyyy. But maybe I can have today's date in YYYY-mm-dd format. So maybe I have to do more than one date conversion. For example, 06/23/2015 or 2015-06-23 (today) should be at least three days less than the date of my SESSION (06/26/2015, for example).

HOW DO I DO IT?

    
asked by anonymous 23.06.2015 / 15:22

1 answer

0

You have to add another three days to the current date to make this comparison:

$data = $_SESSION['buscaReserva']['dataInicio'];
$hoje = date("Y-m-d");

$data = strtotime($data);
$hojeMaisTres = date('Y-m-d',strtotime($date . "+3 days"));

if ($data > $hojeMaisTres) {
    // Do something
} else {
    // Do nothing
}
    
23.06.2015 / 16:31