A JavaScript function to parse a CRM Date that returns a JavaScript Date object. This method can be used in both 2011 and 4.0
//parsing
function parseDate(xmlDate)
{
if (!/^[0-9]{4}\-[0-9]{2}\-[0-9]{2}/.test(xmlDate)) {
throw new RangeError("xmlDate must be in ISO-8601 format YYYY-MM-DD.");
}
return new Date(xmlDate.substring(0,4), xmlDate.substring(5,7)-1, xmlDate.substring(8,10));
}
// and using
// In CRM 4.0
if(retrievedOpp.attributes["estimatedclosedate"] != null && retrievedOpp.attributes["estimatedclosedate"] != undefined){
crmForm.all.new_estimatedclosedate.DataValue = parseDate(retrievedOpp.attributes["estimatedclosedate"].value);}
// In CRM 2011
if(retrievedOpp.attributes["estimatedclosedate"] != null && retrievedOpp.attributes["estimatedclosedate"] != undefined){
Xrm.Page.data.entity.attributes.get('estimatedclosedate').setValue(parseDate( Xrm.Page.data.entity.attributes.get('new_closedate').getValue()));}
Reference :- http://crmpro.blogspot.in/2009/11/javascript-function-to-parse-xml-iso.html