I have a couple of rows with some manualy inserted dates in this format (DD.MM.YYYY) and I would like to change it's color if the today's date is higher or lower than that. For that, I used the following code:
<?php
$date_now = date("d.m.y"); // this format is string comparable
$date = get_sub_field('inserteddate');
if ($date_now > $date) {
echo '<font color="green"> '.$date.' </font>';
}else{
echo '<font color="red"> '.$date.' </font>';
}
?>
The code does work, but some dates are red even if the today's date is higher than the value of them. For example...
22.05.2011 - It turns red. 29.05.2011 - It turns red. 31.03.2013 - It turns red. 21.04.2013 - It turns red.
And so on... I don't get it, what am I doing wrong? Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire