SHARE
TWEET

Untitled

a guest Jun 7th, 2012 45 Never
  1. var values  = $(".updatetime").html().split(":");
  2. // var values = container.nodeValue.split(":");
  3.  
  4. // Because there is only a datetime specified, I assume is the current date
  5. var now = new Date();
  6. var time = new Date(now.getFullYear(), now.getMonth(), now.getDate(),
  7.                     values[0], values[1], values[2]).getTime();
  8.  
  9. setInterval(function() {
  10.     time += 1000;
  11.     var date = new Date(time);
  12.     var values = [date.getHours(), date.getMinutes(), date.getSeconds()];
  13.  
  14.     for (var i = 0; i < 3; i++)
  15.         if (values[i] < 10)
  16.             values[i] = "0" + values[i];
  17.  
  18.     //container.nodeValue = values.join(":");
  19.    $(".updatetime").html(values.join(":"));
  20. }, 1000);
RAW Paste Data
Top