Javascript-has a countdown two values are written by PHP do not know how to write a master to write down

Source: Internet
Author: User
javascriptjsphp Time Stamp Countdown

Look at someone else's website on a cycle countdown, copy found on the site can be automatically 3 days cycle countdown, check the code found that the site of the code there are two values Var servertime and Var htime is always changing, I copied the source code is fixed value so the countdown after the end of the display 0 will not be re-countdown. Those two values should be written in PHP, so you can only see the results when viewing the source code.
Ask the following two values of the PHP code should be how to write (below the current value is I copy time the value of 1000 is fixed the other two sets of numbers are always changing)
var servertime = 1470186666 * 1000;
var htime = 226134000;
The time code is as follows (Div and CSS are not copied in), the current date can be three days to start again, the countdown is the two values do not know how the PHP code is calculated

Reply content:

Nstimer Write a countdown
----------------------Comrade Hello, I am csdn quiz robot Small N, the life of the Organization to provide you with the reference answer, programming has not been successful, comrades still need to work!

.. Used to help others write the pure JS, their own time to set the countdown is good, indirect recursive call, will be infinite loop down//js part of the var = 24*60*60*2; Countdown two days, I set//Output information function begin () {var today=new Date () var day =today.getdate () var dat=today.getmonth () var future=day+2 document.getelemen Tbyid (' Now '). Innerhtml= "Current Time" +dat+ "month" +day+ "Countdown Start" Leasttime () document.getElementById ("Futur E "). Innerhtml=" Estimated end time "+dat+" month "+future}//Time countdown function Functions Leasttime () {VA                R ho=time/(60*60);                var mi= (time/60)% var se=time%60 mi=parseint (mi) ho=parseint (HO)                Ho=checktime (HO) se=checktime (SE) mi=checktime (mi) time-=1;              document.getElementById ("Last"). innerhtml=ho+ ":" +mi+ ":" +se//Countdown End If (time==0) {//           Reset the timer and start the timer again     time=30;            Begin ()} setTimeout ("Leasttime ()", 1000); }//Convert time format to function checktime (i) {if (i<10) {i= "                 0 "+ i} return i}//html section

Start
  var curtime = number ("1470453405");//Current time var endTime = number ("");//end time var timeoutlimit = groupendtime-curtime;    var countdown = Timeoutlimit;       Runcountdown ();            function Runcountdown () {var iday,ihour,iminute,isecond;                if (Countdown >= 0) {iday = parseint (COUNTDOWN/3600/24);                Ihour = parseint ((countdown/3600)%24);                Iminute = parseint ((COUNTDOWN/60)%60);                Isecond = number (countdown%60). toFixed (1);                    if (countdown<=0) {cleartimeout (timeoutlimit);                window.location.href = '/goods/item?id= ' +gid; } else {if (countdown> (3600*24)) {$ (' #rigTime '). html (iday+ ' days ' +ihour+ ' hours ' +imin                    Ute+ ' +isecond+ ' seconds ');                    }else{$ (' #rigTime '). html (ihour+ ' hours ' +iminute+ ' +isecond+ ' seconds ');       } countdown = (countdown-0.1). toFixed (1);             Timeoutlimit = SetTimeout ("Runcountdown ()", 100); }            }       }
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.