Problem with date!

2

I have this snippet of code:

if ($informations->fundation_date != $dateFoundation) {
    echo 'estou no echo diferente do date';
    $alter .= 'fundation_date/';
} else {
    echo 'esta igual date';
}

echo'data antiga: '.$informations->fundation_date;
echo'data nova: '.$dateFoundation;

Use postgree database; I'm comparing whether the date has changed in input , but even when I do not change the date it comes different. Because in the bank (fundation_date) comes as 1995-05-11 and already in input 05/11/1995. How can I do that, but that they are the same when it is so?

    
asked by anonymous 29.09.2016 / 13:30

1 answer

0

You can use two functions together: date () and strtotime () .

$dateFoundation = $_POST['data'];
$dateFoundation = date('Y-m-d', strtotime($dateFoundation));

if($informations->fundation_date != $dateFoundation){
   echo "Diferente!";
}
else{
   echo "Igual!";
}
    
29.09.2016 / 13:33