alert();
var START_DATE = new Date("July 27, 2010 13:30:00"); // put in the starting date here
var INTERVAL = 1; // in seconds
var INCREMENT = 1; // increase per tick
var START_VALUE = 9001; // initial value when it's the start date
var count = 0;
var msInterval = INTERVAL * 100;
var now = new Date();
count = parseInt((now - START_DATE)/msInterval) * INCREMENT + START_VALUE;
alert(formatDate(count))
document.getElementById('counter').innerHTML = formatDate( count);
setInterval(function(){count += INCREMENT; document.getElementById('counter').innerHTML = formatDate( count); }, msInterval);
function formatDate(d1)
{
var d1=new Date(d1*500);
var curr_year = d1.getFullYear();
var curr_month = d1.getMonth() + 1; //Months are zero based
if (curr_month < 10)
curr_month = "0" + curr_month;
var curr_date = d1.getDate();
if (curr_date < 10)
curr_date = "0" + curr_date;
var curr_hour = d1.getHours();
if (curr_hour < 10)
curr_hour = "0" + curr_hour;
var curr_min = d1.getMinutes();
if (curr_min < 10)
curr_min = "0" + curr_min;
var curr_sec = d1.getSeconds();
if (curr_sec < 10)
curr_sec = "0" + curr_sec;
var newtimestamp = curr_year + "-" + curr_month + "-" + curr_date + " " + curr_hour + ":" + curr_min + ":" + curr_sec;
return newtimestamp;
}
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.