php倒计时

 <?php

 function left_time($end_date){
    $unix_timestamp=strtotime($end_date);
       $date = $unix_timestamp-time();
       $day = $date/60/60/24;
       $days = (int)$day;
       $hour = $date/60/60 - $days*24;
       $hours = (int)$hour;
       $minute = $date/60 - $days*24*60 - $hours*60;
       $minutes = (int)$minute;
       $second = $date - $days*24*60*60 - $hours*60*60 - $minutes*60;
       $seconds = (int)$second;
       $result = array($days,$hours,$minutes,$seconds);
    if($seconds>0){
   return $result;
    }else{
   return 0;
    }
 }

 $end_date="2010-11-3";
 $left_time=left_time($end_date);
 if(is_array($left_time)){
  foreach($left_time as $key=>$value){
   if($key==0){
    echo $value."天";
   }elseif($key==1){
    echo $value."时";
   }elseif($key==2){
    echo $value."分";
   }elseif($key==3){
    echo $value."秒";
   }
  }
 }
 ?>

    A+
发布日期:2021年07月14日  所属分类:未分类

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: