I'm trying to show on my site banner's that are not expired due date, I have in my bank a banner with the following dates:
The current date is: 2015-02-07
Expiry date: 2015-02-08
The script I wrote looks like this:
<?php if ($totalRows_rsBanner > 0) { ?>
<?php do {
$imagem = substr($row_rsBanner['imagem'],3);
$url = $row_rsBanner['url'];
$DataAtual = date("Y-m-d"); // data atual
$timestamp_DataAtual = strtotime($DataAtual); // converte para timestamp Unix
$DataExpiracao = $row_rsBanner['data_expiracao']; // data de expiração do anúncio
$timestamp_DataExpiracao = strtotime($DataExpiracao); // converte para timestamp Unix
?>
<?php if ($timestamp_DataAtual > $timestamp_DataExpiracao){ ?>
<li><a href="<?php echo $url; ?>"><img src="<?php echo $imagem; ?>"></a></li>
<?php } ?>
<?php } while ($row_rsBanner = mysql_fetch_assoc($rsBanner)); ?>
<?php } ?>
The field of data_expiracao
is in the format Date
.