Converting XML Timestamp to Javascript Date

From CDYNE Wiki
Jump to: navigation, search

This javascript function will convert a timestamp from XML to a JavaScript date.

CDYNE's use

This works great with our Phone Notify! service when you are trying to send a phone call at an exact time or if you to use the responses back from our xml Web Service.

Code Example

Example:

var StartT = "2006-08-29T01:18:15.001Z";
Status.innerText = TimeStampToDate(StartT);

Function:

function TimeStampToDate(xmlDate)
{
var dt = new Date();
var dtS = xmlDate.slice(xmlDate.indexOf('T')+1, xmlDate.indexOf('.'))
var TimeArray = dtS.split(":");
dt.setUTCHours(TimeArray[0],TimeArray[1],TimeArray[2]);
dtS = xmlDate.slice(0, xmlDate.indexOf('T'))
TimeArray = dtS.split("-");
dt.setUTCFullYear(TimeArray[0],TimeArray[1],TimeArray[2]);
return dt;
}
Personal tools
Namespaces

Variants
Actions
Navigation
Tools

Trial Key