Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. export function convertTime(seconds) {
  2. var seconds = parseInt(seconds, 10)
  3. var hours = Math.floor(seconds / 3600)
  4. var minutes = Math.floor((seconds - (hours * 3600)) / 60)
  5. var seconds = seconds - (hours * 3600) - (minutes * 60)
  6. if ( !!hours ) {
  7. if ( !!minutes ) {
  8. return `${hours}h ${minutes}m ${seconds}s`
  9. } else {
  10. return `${hours}h ${seconds}s`
  11. }
  12. }
  13. if ( !!minutes ) {
  14. return `${minutes}m ${seconds}s`
  15. }
  16. return `${seconds}s`
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement