-2

In where do i add when the timer gets to 0 it exectues a php file for example joined.php and how would i make it so that it also counts days

    <script>
var myreset = [21,37,00]; // at what time to reset - 19:40:00

var mycountdown = startCountdown();

function startCountdown(){
    var enddate = calculateEndDate();
  return setInterval(function(){tickTock(calculateStartDate(),enddate)}, 1000);
}
function calculateStartDate(){ //this needs to be edited if using the server time
    return new Date();
}
function calculateEndDate(){
    var enddate = new Date();
    enddate.setHours(myreset[0]);
    enddate.setMinutes(myreset[1]);
    enddate.setSeconds(myreset[2]);
    return enddate;
}
function tickTock(startdate, enddate){
  var diff = enddate.getTime() - startdate.getTime(); 
  d = diff >= 0 ? diff : diff + 24*3600*1000;
  var h = Math.floor(d / 3600 / 1000);
  var m = Math.floor(d / 60 / 1000) - 60*h; 
  var s = Math.floor(d / 1000) - 3600*h - 60*m; 
  printCountdown(h,m,s);
}
function pluralize(word,count){
      return (count > 1) ? word+'s ' : word+' ';
}
function printCountdown(h,m,s){
  var t = h + pluralize(' hour',h)+ m+pluralize(' minute',m)+ s + pluralize(' and second',s);
  $('#mycountdown').html(t); 
}
</script> 
Karl1337
  • 13
  • 3

1 Answers1

-1

Use ajax. Doing it with native JavaScript might be a bit of a hassle, I suggest using for it a library like Jquery that has a built-in method for ajax requests: jQuery.ajax

Tomer Gal
  • 933
  • 12
  • 21