Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
The last time I worked with Flash and Socket connections was in AS1. A recent project required flash connecting to a Socket, and sending receiving information - we figured it would be easy enough - we all know about the socket policy documents and c…
In this tutorial viewers will learn how to create a basic shape tween animation in Flash including shape hints for smooth animation Open a new document in Flash: Draw a shape: Select another frame (how long you want the tween to be): Right click and…
The goal of the tutorial is to teach the user how to how to record live broadcast.

809 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