0

Hi am just new to jQuery while leaning online I come across this script

var START_DATE = new Date("July 6, 2015 21:52:00");
var INTERVAL = 20;
var INCREMENT = 1;
var START_VALUE = 9001;
var count = 0;

window.onload = function()

{
    var msInterval = INTERVAL * 1000;
    var now = new Date();
    count = parseInt((now - START_DATE) / msInterval) * INCREMENT + START_VALUE;
    document.getElementById('counter').innerHTML = count;
    setInterval("count += INCREMENT; document.getElementById('counter').innerHTML = count;", msInterval);

}

I would like to add the comma separator to numbers such as 9001 to appear as 9,001, kindly help me on this Regards

Anik Islam Abhi
  • 25,137
  • 8
  • 58
  • 80
  • 1
    possible duplicate of [How to print a number with commas as thousands separators in JavaScript](http://stackoverflow.com/questions/2901102/how-to-print-a-number-with-commas-as-thousands-separators-in-javascript) – The_Black_Smurf Jul 07 '15 at 02:37

1 Answers1

0

Hi With The_Black_Smurf help am glad I was able to a chive what I was looking for.

<script type="text/javascript">

var START_DATE = new Date("July 7, 2015 07:00:00"); // put in the starting date here
var INTERVAL = 20; // in seconds
var INCREMENT = 1; // increase per tick
var START_VALUE = 2824327; // initial value when it's the start date
var count=2824327;
console.log(count.toLocaleString('en-US'))

window.onload = function()
{
  var msInterval = INTERVAL * 1000;
  var now = new Date();
  count = parseInt((now - START_DATE) / msInterval) * INCREMENT + START_VALUE;
  document.getElementById('counter').innerHTML = count.toLocaleString('en-US');
  setInterval(function() {
  count += INCREMENT;
  document.getElementById('counter').innerHTML =   count.toLocaleString('en-US');
  }, msInterval);

}

</script>
<style>

.death_number{font-size:18px; color:#FFFFFF; background-color:#000000; padding:5px 25px; line-height:20px; font-weight:bold; width:auto; text-align:center;}
</style>
<div id="counter" class="death_number"></div>