client side code

C

Claudia Fong

I got this code in my client side but I'm not sure what this supposed to
do.. can someone tell me?

function FormatXMLTime(aTime)
{
// Extract the date
//
var date = aTime.substring(0, aTime.indexOf("T", 0));

// Remove the date.
//
var temp = aTime.replace(date, "");
var temptime = temp.replace("T", "");

// Extract the time.
//
var time = temptime.substring(0, temptime.indexOf("-", 0));

return time;
}

return time won't return anything.. if I put this code
return date + " " + time; then it will return only the date
But I check the format of the date/time in the xml file and it's like
this:

2007-12-04T09:26:59.953+00:00

So does that means this function won't return the time or the function
is not getting the substring of the time?






Cheers!

Claudi
 
H

Hans Kesting

Claudia Fong explained on 12-12-2007 :
I got this code in my client side but I'm not sure what this supposed to
do.. can someone tell me?

function FormatXMLTime(aTime)
{
// Extract the date
//
var date = aTime.substring(0, aTime.indexOf("T", 0));

// Remove the date.
//
var temp = aTime.replace(date, "");
var temptime = temp.replace("T", "");

// Extract the time.
//
var time = temptime.substring(0, temptime.indexOf("-", 0));

return time;
}

return time won't return anything.. if I put this code
return date + " " + time; then it will return only the date
But I check the format of the date/time in the xml file and it's like
this:

2007-12-04T09:26:59.953+00:00

So does that means this function won't return the time or the function
is not getting the substring of the time?

"temp" should contain "T09:26:59.953+00:00"
"temptime" should contain "09:26:59.953+00:00"
(although you could have gotten here with a substring *from* the "T")

but then you search for a "-", did you mean a "+"?

And a different way could be:
var date = aTime.substring(0, 10);
var time = aTime.substring(11, 8);
as the lengths are fixed.

Hans Kesting
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top