Solved

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

Posted on 2009-06-30
2
357 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML error 2 41
Play RTMP without Flash 3 539
Create html table using xsl 8 36
XML XSL Message 3 22
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

803 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