Solved

AS3/XML convert xml timestamps into an hourly time for display in Flash

Posted on 2009-06-30
2
351 Views
Last Modified: 2013-11-11
I need to convert this xml node into standard 24 hr time.  For example: DepartureDate="2009-06-30 15:00" needs to be displayed as 3:00P or something similar.  How do I go about accomplishing this?

Thanks for all the support, this is drivin me nuts!

XML:

<fh:FlightHistory FlightHistoryId="163871394" DepartureDate="2009-06-30 15:00" ArrivalDate="2009-06-30 16:35" PublishedDepartureDate="2009-06-30 15:00"
 

AS3 xml path into parsed dynamic textfields:

Flights.flight_mc.schedTime_txt.text = contentInput.channel.item.someNamespace::FlightHistory[0].@DepartureDate;

Open in new window

0
Comment
Question by:cubical38
2 Comments
 
LVL 37

Accepted Solution

by:
CyanBlue earned 500 total points
ID: 24755856
You basically have to do a simple math like this...

CyanBlue
var timeStr:String = "2009-06-30 15:00";

var dt:String = timeStr.split(" ")[0];

var hr:String = timeStr.split(" ")[1].split(":")[0];

var mn:String = timeStr.split(" ")[1].split(":")[1];

var ampm:String = "AM";
 

if (parseInt(hr) > 12)

{

	ampm = "PM";

	hr = (parseInt(hr) - 12).toString();

}
 

var newTimeStr:String = dt + " " + hr + ":" + mn + " " + ampm;

trace("newTimeStr = " + newTimeStr);     // newTimeStr = 2009-06-30 3:00 PM

Open in new window

0
 

Author Closing Comment

by:cubical38
ID: 31598545
Perfection!  Thank you!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Converting BLOB to XMLTYPE 12 99
Trouble parsing soap xml result 3 39
Post xml via PHP Soap Client 3 37
Transform XML to Excel using XSL 1 23
The Problem How to write an Xquery that works like a SQL outer join, providing placeholders for absent data on the outer side?  I give a bit more background at the end. The situation expressed as relational data Let’s work through this.  I’ve …
I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
The goal of the tutorial is to teach the user how to how to load their YouTube profile onto Flash Media Live Encoder.
The goal of the tutorial is to teach the user how to select the video input device. Make sure you have an input device that in connected and work and recognized by Adobe Flash Media Live Encoder and select it in the “video input” menu.

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now