Countdown functions: php and countdown functions: php
<Script type = "text/javascript" language = "javascript"> function datetime_to_unix (datetime) {var tmp_datetime = datetime. 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); // you can call the countdown function every second. // you can call the countdown function every second, second ID 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 the activity End Time To 1410793200000 var time_start = datetime_to_unix (" <? Php echo date ('Y-m-d H: I: s', $ product ['start']);?> ") * 1000; // set the activity End Time To 1409545430000 // defines the countdown function count_down () {var time_now = new Date (); // obtain the current time time_now = time_notesgettime (); // obtain the current timestamp var time_distance = time_end-time_now; // time difference: activity End Time minus current time var time_startd = time_start-time_now; // time difference: Activity start time 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; // converts the difference of subtraction to hour int_hour = Math. floor (time_startd/3600000) time_startd-= int_hour * 3600000; // converts the difference of subtraction to minute int_minute = Math. floor (time_startd/60000) time_startd-= int_minute * 60000; // converts the difference of subtraction to int_second = Math. floor (time_startd/1000) // when the judgment hour is less than 10, add 0 in front to carry out placeholder if (int_hour <10) int_hour = "0" + int_hour; // when the judgment minute is less than 10, the first plus 0 is used for placeholder if (int_minute <10) int_minute = "0" + int_minute; // when the judgment seconds are less than 10, if (int_second <10) int_second = "0" + int_second; var timea = document. getElementById ("timea"); timea. innerHTML = 'start time: <label id = "times_day"> '+ int_day +' </label> <label id = "times_hour"> '+ int_hour +' </label> <label id = "times_minute"> '+ int_minute +' </label> minute <label id = "second"> '+ int_second +' </label> second '; setTimeout ("count_down ()", 1000);} else {if (time_distance> = 0) {// converts the difference of subtraction to days int_day = Math. floor (time_distance/86400000) time_distance-= int_day * 86400000; // converts the difference of subtraction to hour int_hour = Math. floor (time_distance/3600000) time_distance-= int_hour * 3600000; // converts the difference of subtraction to minute int_minute = Math. floor (time_distance/60000) time_distance-= int_minute * 60000; // converts the difference of subtraction to int_second = Math. floor (time_distance/1000) // when the judgment hour is less than 10, add 0 in front to carry out placeholder if (int_hour <10) int_hour = "0" + int_hour; // when the judgment minute is less than 10, the first plus 0 is used for placeholder if (int_minute <10) int_minute = "0" + int_minute; // when the judgment seconds are less than 10, if (int_second <10) int_second = "0" + int_second; // display the countdown effect when = int_day; when = int_hour; when = int_minute; time_second.innerHTML = int_second; setTimeout ("count_down ()", 1000);} else {var timea = document. getElementById ("timea"); timea. innerHTML = '<font size = "3px"> remaining time: the application time has passed </font>' ;}}</script>
Is there a computer date difference function in php? A countdown
$ Time = abs (strtotime ("2008-08-08")-strtotime (date ("Y-m-d")/86400 );
$ Time is what you want.
Just write it as a function.
Echo dushuTime ("2008-08-08 ");
Function dushuTime ($ target ){
$ Time = abs (strtotime ($ target)-strtotime (date ("Y-m-d")/86400 );
Return $ time;
}
Php countdown
<? Php
Function compDate ($ Date_1, $ Date_2 ){
$ Date_List_1 = explode ("-", $ Date_1 );
$ Date_List_2 = explode ("-", $ Date_2 );
$ D1 = mktime (0, 0, 0, $ Date_List_1 [1], $ Date_List_1 [2], $ Date_List_1 [0]);
$ D2 = mktime (0, 0, $ Date_List_2 [1], $ Date_List_2 [2], $ Date_List_2 [0]);
$ Days = round ($ d1-$ d2)/3600/24 );
Return $ Days;
}
$ Today = date ("Y-m-d H: I: s ");
$ Day = "00:00:00 ";
$ Days = compDate ($ day, $ today );
Echo $ days;
?>