Home>
<div data-end="">
<span>00</span>
<span>00</span>s
<span>000</span>
</div>
<script type="text/javascript" src="jquery-2.1.4.min.js"<&/;script
<script type="text/javascript">
 $.extend ($. fn, {
  fntimecountdown:function (d) {
   this.each (function () {
    var $this=$(this);
    var o={
     hm:$this.find (". hm"),     sec:$this.find (". sec"),     mini:$this.find (". mini"),     hour:$this.find (". hour"),     day:$this.find (". day"),     month:$this.find (". month"),     year:$this.find (". year")
    };
    var f={
     haomiao:function (n) {
      if (n<10) return "00" + n.tostring ();
      if (n<100) return "0" + n.tostring ();
      return n.tostring ();
     },     zero:function (n) {
      var _n=parseint (n, 10);//parse the string,Returns an integer
      if (_n>0) {
       if (_n<= 9) {
        _n="0" + _n
       }
       return string (_n);
      } else {
       return "00";
      }
     },     dv:function () {
      //d=d || date.utc (2050, 0, 1);//If time is not defined,Then we set the countdown date to January 1, 2050
      var _d=$this.data ("end") || d;
      var now=new date (),       enddate=new date (_d);
      //The difference in seconds now and in the future
      //alert (future.gettimezoneoffset ());
      var dur=(enddate-now.gettime ())/1000, mss=enddate-now.gettime (), pms={
       hm:"000",       sec:"00",       mini:"00",       hour:"00",       day:"00",       month:"00",       year:"0"
      };
      if (mss>0) {
       pms.hm=f.haomiao (mss%1000);
       pms.sec=f.zero (dur%60);
       pms.mini=math.floor ((dur/60))>0?f.zero (math.floor ((dur/60))%60):"00";
       pms.hour=math.floor ((dur/3600))>0?f.zero (math.floor ((dur/3600))%24):"00";
       pms.day=math.floor ((dur/86400))>0?f.zero (math.floor ((dur/86400))%30):"00";
       //Month, calculated based on actual average monthly seconds
       pms.month=math.floor ((dur/2629744))>0?f.zero (math.floor ((dur/2629744))%12):"00";
       //Year, according to the return year 365 days 5:48:46
       pms.year=math.floor ((dur/31556926))>0?math.floor ((dur/31556926)):"0";
      } else {
       pms.year=pms.month=pms.day=pms.hour=pms.mini=pms.sec="00";
       pms.hm="000";
       //alert ("Ended");
       return;
      }
      return pms;
     },     ui:function () {
      if (o.hm) {
       o.hm.html (f.dv (). hm);
      }
      if (o.sec) {
       o.sec.html (f.dv (). sec);
      }
      if (o.mini) {
       o.mini.html (f.dv (). mini);
      }
      if (o.hour) {
       o.hour.html (f.dv (). hour);
      }
      if (o.day) {
       o.day.html (f.dv (). day);
      }
      if (o.month) {
       o.month.html (f.dv (). month);
      }
      if (o.year) {
       o.year.html (f.dv (). year);
      }
      settimeout (f.ui, 1);
     }
    };
    f.ui ();
   });
  }
 });
</script>
<script type="text/javascript">
 $("#fntimecountdown"). fntimecountdown ("2018/07/08 18:45:13");
</script>
  • Previous Implementation method of OAuth extension and QQ interconnection login in Yii2
  • Next Working with Data in ASPNET 20 No 52: Uploading Files with FileUpload