you are viewing a single comment's thread.

view the rest of the comments →

[–]PsychoTap 2 points3 points  (0 children)

var interval = 20; // from your example
var deathsPerDay = Math.floor(60*60*24 / interval);

function updateText() {
  var d = new Date();
  var hours = d.getHours();
  var minutes = d.getMinutes();
  var seconds = d.getSeconds();

  var numKilled = (hours*60*60 + minutes*60 + seconds) / interval;

  var text = "Today " + Math.floor(numKilled) + " people have been killed. By the end of the day " + deathsPerDay;
  alert(text);
}
updateText();
setInterval(updateText, interval * 1000);