Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Created by AroliS^
- You are not allow to publish this code as your
- All credits goes to me.
- */
- //example code
- timeFormat( old.timeStamp - new.timeStamp );
- //function
- function timeFormat( ms )
- {
- var years
- , months
- , days
- , hours
- , mins
- , secs;
- secs = parseInt( ms * 0.001, 10 );
- mins = parseInt( secs * 0.0166667, 10 );
- hours = parseInt( mins * 0.0166667, 10 );
- days = parseInt( hours * 0.0416667, 10 );
- months = parseInt( days * 0.0328767, 10 );
- years = parseInt( months * 0.0833334, 10 );
- years = parseInt( (years%31536000), 10);
- months = parseInt( (months%2678400), 10);
- days = parseInt( (days%86400), 10);
- hours = parseInt( (hours%3600), 10 );
- minutes = parseInt( (mins%60), 10 );
- secs = parseInt( (secs%60), 10 );
- if ( years != 0 ) return `${years} year(s)`;
- if ( months != 0 ) return `${months} month(s)`;
- if ( days != 0 ) return `${days} day(s)`;
- if ( hours != 0 ) return `${hours} hour(s)`;
- if ( mins != 0 ) return `${mins} min(s)`;
- if ( secs != 0 ) return `${secs} sec(s)`;
- }
Advertisement
Add Comment
Please, Sign In to add comment