Reputation: 1
I am creating an XML based screensaver using Flash CS3, everything works fine. However, on the XML output file the date output format remains unformatted (YYYY-MM-DD T00:00:00+00:00
). Ideally, a UK date (DD/MM/YYYY
) format would be output.
Below is a sample of the ActionScript code driving an XML file
// Load up variables with XML element data
var item_data:Array = new Array();
item_data[0] = xml_item.id;
item_data[1] = xml_item.Product_Name;
item_data[2] = xml_item.Product_Language;
item_data[3] = xml_item.dateCreated;
item_data[4] = xml_item.antDeadlineDate;
item_data[5] = xml_item.comments;
item_data[6] = xml_item.webPdf;
item_data[7] = xml_item.conCheck;
// Set output variable
output = "<b>Job ID</b>:" + item_data[0] + "\n";
output += "<b>Product Name</b>: " + item_data[1] + "\n";
output += "<b>Language</b>: " + item_data[2] + "\n";
output += "<b>Date Created</b>: " + item_data[3] + "\n";
output += "<b>Anticipated Deadline</b>: " + item_data[4] + "\n";
output += "<b>Comments</b>: " + item_data[5] + "\n";
output += "<b>PDFs created</b>: " + item_data[6] + "\n";
output += "<b>Controller Check</b>: " + item_data[7] + "\n\n\n\n";
Upvotes: 0
Views: 234
Reputation: 6258
you can use also Regular Expression
var xmlDateTime:RegExp = /([0-9]{4})-(0[0-9]|1[012])-([012][0-9]|3[01])T([01][0-9]|2[0-3])(:[0-5][0-9]){2}(.[0-9]{3}){0,1}(\+|-)([01][0-9]|2[0-3]):[0-5][0-9]/g;
var dateString = xml_item.dateCreated.toString().replace(xmlDateTime, "$3/$2/$1");
Upvotes: 2
Reputation: 5459
To convert a date string in this format YYYY-MM-DD T00:00:00+00:00 to this format DD/MM/YYYY you can do this:
var dateOld:String = '1999-01-05 T00:00:00+00:00';
var dateParts:Array = dateOld.substring(0, 10).split('-');
var dateNew:String = dateParts[2] + '/' + dateParts[1] + '/' + dateParts[0];
Upvotes: 1