Countdown Correlation function PHP

Source: Internet
Author: User

<script type= "Text/javascript" language= "JavaScript" >function Datetime_to_unix (datetime) {var tmp_datetime = da    Tetime.replace (/:/g, '-');    Tmp_datetime = tmp_datetime.replace (//g, '-');    var arr = tmp_datetime.split ("-");    var now = new Date (DATE.UTC (arr[0],arr[1]-1,arr[2],arr[3]-8,arr[4],arr[5)); Return parseint (Now.gettime ()/1000);} SetTimeout ("Count_down ()", 1000);//Set each second to invoke the Countdown function//Depending on the day, when. The ID of the second to find the corresponding element var time_day = document.getElementById ("Times_day"); var time_hour = document.getElementById ("Times_ Hour ") var Time_minute = document.getElementById (" Times_minute "); var Time_second = document.getElementById (" second ") var time_end = Datetime_to_unix ("<?php echo date (' y-m-d h:i:s ', $product [' Stop ']);?  > ") *1000; Set activity end Time 1410793200000 var time_start = Datetime_to_unix ("&LT;?

PHP echo Date (' y-m-d h:i:s ', $product [' Start ']); > ") *1000; Set activity end time 1409545430000//define Countdown function Count_down () {var time_now = new Date (); Gets the current time Time_now = Time_now.gettime ();//Gets the current timestamp var time_distance = Time_end-time_now; Time difference: End of activity minus current time Var Time_startd=time_start-time_now; Time difference: Activity starts minus current time Var int_day, Int_hour, Int_minute, Int_second; if (time_startd>0) {int_day = Math.floor (time_startd/86400000) TIME_STARTD-= Int_day * 86400000; The subtraction difference is converted into hours Int_hour = Math.floor (time_startd/3600000) TIME_STARTD-= Int_hour * 3600000; The subtraction difference is converted into minutes Int_minute = Math.floor (time_startd/60000) TIME_STARTD-= Int_minute * 60000; The subtraction difference is converted into seconds Int_second = Math.floor (time_startd/1000)//inferred hours are less than 10 o'clock. Front plus 0 for placeholder if (Int_hour <) Int_hour = "0" + int_hour; Inferred minute is less than 10 o'clock, preceded by 0 for placeholder if (Int_minute <) Int_minute = "0" + int_minute; Inferred seconds less than 10 o'clock。 Front plus 0 for placeholder if (Int_second <) Int_second = "0" + int_second; var Timea = document.getElementById ("Timea"); Timea.innerhtml= ' Start time: <label id= "Times_day" > ' +int_day+ ' </label> days <label id= "Times_hour" > ' +int_ hour+ ' </label> <label id= "Times_minute" > ' +int_minute+ ' </label> sub <label id= "Second" > ' +int_ Second+ ' </label> s '; SetTimeout ("Count_down ()", 1000); }else{if (time_distance >= 0) {//subtract the difference into days Int_day = Math.floor (time_distance/86400000) Time_distance-= Int_day * 86400000; The subtraction difference is converted into hours Int_hour = Math.floor (time_distance/3600000) time_distance-= Int_hour * 3600000; The subtraction difference is converted into minutes Int_minute = Math.floor (time_distance/60000) time_distance-= Int_minute * 60000; The subtraction difference is converted into seconds Int_second = Math.floor (time_distance/1000)//inferred hours are less than 10 o'clock. Front plus 0 for placeholder if (Int_hour <) Int_hour = "0" + int_hour; InferMinute is less than 10 o'clock. Front plus 0 for placeholder if (Int_minute <) Int_minute = "0" + int_minute; Infers that the number of seconds is less than 10 o'clock. Front plus 0 for placeholder if (Int_second <) Int_second = "0" + int_second; Display Countdown effect time_day.innerhtml = Int_day; time_hour.innerhtml = Int_hour; time_minute.innerhtml = Int_minute; time_second.innerhtml = Int_second; SetTimeout ("Count_down ()", 1000); }else{var Timea = document.getElementById ("Timea"); Timea.innerhtml= ' <font size= "3px" > Remaining time: Application time is over </font> '; }}} </script>


Countdown Correlation function PHP

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.