Hi all!!
Can anyone tell me why using this method of the Date() object does not produce a "two digit" printout of the minutes and seconds under the value of 10 ???
var time = new Date();
var m = time.getMinutes();
if (m.length < 2) m= "0"+m;
var s= time.getSeconds();
if(s.length < 2) s = "0"+ s;
var t = m+ ":" + ":" s;
return t;
My workaround using the following method produces a 2 digit readout:
if(m<10) m = "0"+m
if(s<10) s = "0"+s
Can I not use ".length" method of an object to determine the length of the output??
I saw the use of the .length code previously in another program
but I can't get it to work properly .
Thanks !!
angelo
Can anyone tell me why using this method of the Date() object does not produce a "two digit" printout of the minutes and seconds under the value of 10 ???
var time = new Date();
var m = time.getMinutes();
if (m.length < 2) m= "0"+m;
var s= time.getSeconds();
if(s.length < 2) s = "0"+ s;
var t = m+ ":" + ":" s;
return t;
My workaround using the following method produces a 2 digit readout:
if(m<10) m = "0"+m
if(s<10) s = "0"+s
Can I not use ".length" method of an object to determine the length of the output??
I saw the use of the .length code previously in another program
but I can't get it to work properly .
Thanks !!
angelo
Comment