Skip to content

Instantly share code, notes, and snippets.

@martinbean
Created July 13, 2016 08:03
Show Gist options
  • Star 36 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save martinbean/2bf88c446be8048814cf02b2641ba276 to your computer and use it in GitHub Desktop.
Save martinbean/2bf88c446be8048814cf02b2641ba276 to your computer and use it in GitHub Desktop.
Convert seconds to HH:MM:SS format in JavaScript.
new Date(seconds * 1000).toISOString().substr(11, 8)
@martinbean
Copy link
Author

martinbean commented Jul 8, 2021

Thanks, works well on Chrome but fails in Safari (14.1.1).

@sidelux It works fine in Safari 14.1.1. It’s just basic JavaScript:

Screenshot 2021-07-08 at 14 22 42

@sidelux
Copy link

sidelux commented Jul 8, 2021

Thanks, works well on Chrome but fails in Safari (14.1.1).

@sidelux It works fine in Safari 14.1.1. It’s just basic JavaScript:

Screenshot 2021-07-08 at 14 22 42

Yes, it was another error. Sorry.

@mohsinraza
Copy link

great

@trungnghia112
Copy link

new Date(seconds * 1000).toISOString().substring(11, 19)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment