Posted By

wizard04 on 09/16/08


Tagged

javascript time number prototype


Versions (?)

Millisecond Equivalent of Time Interval


 / Published in: JavaScript
 

  1. //Gets the millisecond equivalent of an interval
  2. //Example: (2).seconds() == 2000
  3. Number.prototype.seconds = function(){ return this * 1000; };
  4. Number.prototype.minutes = function(){ return this * 60000; }; //60 * 1000
  5. Number.prototype.hours = function(){ return this * 3600000; }; //60 * 60 * 1000
  6. Number.prototype.days = function(){ return this * 86400000; }; //24 * 60 * 60 * 1000
  7. Number.prototype.weeks = function(){ return this * 604800000; }; //7 * 24 * 60 * 60 * 1000

Report this snippet  

You need to login to post a comment.