second to hour minute second


/ Published in: JavaScript
Save to your folder(s)

to_text( int ) -- the int is the number of seconds.


Copy this code and paste it in your HTML
  1. function to_text( s ) {
  2. var second = s % 60;
  3. var hour = Math.floor( (s/60) / 60 );
  4. var minute = Math.floor( (s/60) % 60 );
  5.  
  6. return hour + 'h ' + minute + 'm ' + second + 's';
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.