<?php $end_day = strtotime("20160930"); //yyyymmdd $int = $end_day - time(); $after_day = ceil($int / (24 * 60 * 60)); if($day > 0){ echo 'あと'. $after_day . '日'; } else { echo '終了'; } ?>
3桁の画像で表示する場合、
<?php $countdown = sprintf("%03d",$after_day); if($day < 0){ $countdown = '000'; } ?> <img src="img/no<?php echo substr($countdown, 0, 1) ?>.png" alt=""> <img src="img/no<?php echo substr($countdown, 1, 1) ?>.png" alt=""> <img src="img/no<?php echo substr($countdown, 2, 1) ?>.png" alt="">
コメント