Revision: 8897
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at October 13, 2008 06:34 by gfazioli
Initial Code
/** * CountDown Class * * @author Giovambattista Fazioli * @email [email protected] * @web http://www.undolog.com * * @param dd (string) 'month day, year' * */ function countDown( dd ) { // init target time var target = new Date( dd ); this.targetTime = target.getTime(); /** * refresh countdown */ this.refresh = function() { var today = new Date(); var currentTime = today.getTime(); // time left this._leftMilliseconds = (this.targetTime - currentTime); this._leftSeconds = Math.floor( this._leftMilliseconds / 1000 ); this._leftMinutes = Math.floor( this._leftSeconds / 60 ); this._leftHours = Math.floor( this._leftMinutes / 60 ); // no module this.leftDays = Math.floor( this._leftHours / 24 ); // for print this.leftMilliseconds = this._leftMilliseconds % 1000; this.leftSeconds = this._leftSeconds % 60; this.leftMinutes = this._leftMinutes % 60; this.leftHours = this._leftHours % 24; } this.refresh(); }
Initial URL
http://www.undolog.com/2008/10/13/una-classe-countdown-in-javascript/
Initial Description
A simple countDown class in Javascript:
Initial Title
countDown Class in Javascript
Initial Tags
javascript, class
Initial Language
JavaScript