D
Dr John Stockton
JRS: In article <[email protected]>, dated
Sun, 26 Sep 2004 07:04:22, seen in Don
The concatenation is more effectively done as
var sToday = "" +
today.getMonth()+1) +
today.getDate() +
today.getYear() +
today.getHours() +
today.getMinutes() +
today.getSeconds() ;
Unless you use field separators or leading zeroes or both, the result
will be horribly ambiguous if M<10 xor D<10, or any but not all of h m s
<10 (that assumes the year to be recognisable).
FFF is unwise for general use; follow FIPS 4.1 (if American) or ISO
8601.
The following gives a universally comprehensible result, and, after
thinking about it for the first time, will seem far simpler.
with (new Date()) sToday = ((((
getYear()*100 + (getMonth()+1))*100 + getDate())*100 +
getHours())*100 + getMinutes())*100 + getSeconds()
For leading zeroes AND separators, use <FAQENTRY>
function LZ(x) { return (x<0||x>=10?"":"0") + x }
*** DO NOT MULTI-POST ***
Sun, 26 Sep 2004 07:04:22, seen in Don
function datetimestamp()
{
var today = new Date();
var sToday = (today.getMonth()+1).toString();
sToday += today.getDate().toString();
sToday += today.getYear().toString();
sToday += today.getHours().toString();
sToday += today.getMinutes().toString();
sToday += today.getSeconds().toString();
return sToday;
}
The concatenation is more effectively done as
var sToday = "" +
today.getMonth()+1) +
today.getDate() +
today.getYear() +
today.getHours() +
today.getMinutes() +
today.getSeconds() ;
Unless you use field separators or leading zeroes or both, the result
will be horribly ambiguous if M<10 xor D<10, or any but not all of h m s
<10 (that assumes the year to be recognisable).
FFF is unwise for general use; follow FIPS 4.1 (if American) or ISO
8601.
The following gives a universally comprehensible result, and, after
thinking about it for the first time, will seem far simpler.
with (new Date()) sToday = ((((
getYear()*100 + (getMonth()+1))*100 + getDate())*100 +
getHours())*100 + getMinutes())*100 + getSeconds()
For leading zeroes AND separators, use <FAQENTRY>
function LZ(x) { return (x<0||x>=10?"":"0") + x }
*** DO NOT MULTI-POST ***