Skip to content

How to display datetime in the format with seconds? #1218

Discussion options

You must be logged in to vote

I didn't think the calendar had an option to pick seconds - but you can output it with seconds as you like. Looking above, it seems all you really need to do is check if the minute or second is less than 10 and pre-pend a zero to that, ie.

let minute = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();

Replies: 6 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by lubber-de
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #1218 on October 07, 2020 21:10.