Javascript Date: Ensure getMinutes(), getHours(), getSeconds() puts 0 in front if necessary
Posted
by
Mega Matt
on Stack Overflow
See other posts from Stack Overflow
or by Mega Matt
Published on 2010-07-22T22:03:21Z
Indexed on
2010/12/27
21:55 UTC
Read the original article
Hit count: 101
JavaScript
|date
Hi all,
Looking for a creative way to be sure values that come from the getHours, getMinutes, and getSeconds() method for the javascript Date object return "06"
instead of 6
(for example). Are there any parameters that I don't know about? Obviously I could write a function that does it by checking the length and prepending a "0"
if need be, but I thought there might be something more streamlined than that.
Thanks.
© Stack Overflow or respective owner