R
R
Folks,
Given that ourStr=20091110, I found I can convert the date into
ddmmyyyy using the following function
function convertYYYYMMDD( ourStr )
{
var yyyy=ourStr.substring(0,4);
var mm=ourStr.substring(6,4)
var dd=ourStr.substring(8,6);
return dd+""+mm+""+yyyy;
}
My question is, I believe the syntax is wrong for substring. My
O'Reilly book says
substring(from, to)
Returns a new string that contains characters copied from position
'from' to 'to-1' of 'string'. If to is omitted, the substring extends
to the end of the string.
If this is true, then why do I find dd value is found starting at
position 8, and finishing at position 6 ??? I would expect to be the
reverse (thus, dd=ourString.substring(6,8). And I would expect the
second numeric arg always to be greater than the last since it records
the "to" position.
Is there something I'm not seeing?
thanks
(firefox user)
Given that ourStr=20091110, I found I can convert the date into
ddmmyyyy using the following function
function convertYYYYMMDD( ourStr )
{
var yyyy=ourStr.substring(0,4);
var mm=ourStr.substring(6,4)
var dd=ourStr.substring(8,6);
return dd+""+mm+""+yyyy;
}
My question is, I believe the syntax is wrong for substring. My
O'Reilly book says
substring(from, to)
Returns a new string that contains characters copied from position
'from' to 'to-1' of 'string'. If to is omitted, the substring extends
to the end of the string.
If this is true, then why do I find dd value is found starting at
position 8, and finishing at position 6 ??? I would expect to be the
reverse (thus, dd=ourString.substring(6,8). And I would expect the
second numeric arg always to be greater than the last since it records
the "to" position.
Is there something I'm not seeing?
thanks
(firefox user)