This question already has an answer here:
I am comparing 2 dates and wants to check if the date is current(today),past or future. I don't know bt the data is still coming wrong. Can anyone tell me where I am going wrong?
Here is my code:
<?php
$date1 = date('m-d-Y'); //02-27-2018
$date2 = "02-28-2018";
$dateTimestamp1 = strtotime($date1);
$dateTimestamp2 = strtotime($date2);
if ($dateTimestamp1 > $dateTimestamp2)
{
echo "Future date";
//echo "$date1 is newer than $date2";
}
elseif($dateTimestamp1 < $dateTimestamp2)
{
echo "past Dates";
}
else
{
echo "today Dates";
}
?>
It Should print past dates
instead it is printing today Dates
only.
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire