JRS: In article <oGybd.126897$He1.17615@attbi_s01>, dated Thu, 14 Oct
2004 17:27:48, seen in news:comp.lang.javascript, McKirahan
<Ne**@McKirahan.com> posted :
"Jose" <s.*****@terra.es> wrote in message
news:Wk**********************@telenews.teleline.e s...
how to when i wrote the time on input it shows two points automatic?
(12:23)
Will this help: watch for word-wrap.
var d = new Date();
var h = ((d.getHours()+100)+"").substr(1,2);
var m = ((d.getMinutes()+100)+"").substr(1,2);
var t = h + ":" + m;
document.write(t);
That's not a particularly good way of adding a leading zero in
javascript, though it is in VBScript.
I'd use
function LZ(x) { return (x<0||x>=10?"":"0") + x } // included
var t = LZ(d.getHours() + ':' + LZ(d.getMinutes())
Unless there are systems that give FFF times,
var t = String(d).match(/..:../) // should do.
--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Proper <= 4-line sig. separator as above, a line exactly "-- " (SonOfRFC1036)
Do not Mail News to me. Before a reply, quote with ">" or "> " (SonOfRFC1036)