javascript - Countdown inverted -
anyone can me? example, want countdown timer
inverted, example:
i insert date , hour in javascript or mysql (doesn't matter) , count ..
example: inserted: 01/07/2015
today counter show: 1day 1hour 19min
if don't want use jquery can this:
var starttime = +new date("07/01/2015"); // m/d/y gets timestamp in ms var second = 1000; var minute = second * 60; var hour = minute * 60; var day = hour * 24; var element = document.getelementbyid('timer'); // target element timer function countup() { // time between , start date var time = date.now() - starttime; // days passed since start var days = math.floor(time / day); time -= days * day; // hours passed var hours = math.floor(time / hour); time -= hours * hour; // minutes passed var minutes = math.floor(time / minute); // update element element.innerhtml = days + 'day ' + hours + 'hour ' + minutes + 'min'; settimeout(countup, minute); }; countup();
<span id="timer"></span>
Comments
Post a Comment