View Single Post
Old 12-10-2012, 04:59 PM   PM User | #1
sinsysonline
New Coder

 
Join Date: Dec 2012
Posts: 15
Thanks: 4
Thanked 0 Times in 0 Posts
sinsysonline is an unknown quantity at this point
Auto-Editing XML Node Value - Make timestamp readable

Greetings all,

I have an issue where I am having trouble converting a timestamp into a readable value. These timestamp values are external and I need a simple way to either:

a) Convert it into a readable format (ie. December 16th, 8:54pm)

b) Strip the middle of the data from the node (ie. <Created>2012-12-07T23:22:11.822Z</Created> = strip after 'T' until '.' to just acquire the time (ie. 23:22:11) )

Here is the code I'm initially pulling the data with:

Code:
var i=0,d;
while (d=document.getElementById("Created"+i)) d.innerHTML=xmlDoc.getElementsByTagName("Created")[i++].childNodes[0].nodeValue;
Here is what the node looks like:

Code:
<Created>2012-12-07T23:22:11.822Z</Created>
And here is how it's posted:

Code:
<div id="fitin">
<span id="Body0"></span>
</div>
I suppose I need a script to either convert it into words (ie. December 16th, 8:45pm) or if that's too hard, just pull everything inbetween 'T' and '.' so that I can at least get an accurate time. This is for a large scale LCD that displays real time information.

Any help is appreciated!
sinsysonline is offline   Reply With Quote