Solved

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

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
D3, dragging and rotating. 7 94
XML template problem 4 58
XML to SQL Table using c# 5 47
Image decoding from Camera 3 47
Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
There are times in your Flash CS4 application when you want more than a simple pointer or a hand, and it's hard to find an ideal walk-through to tell you what to do.  I spent a few days recently learning my way around making custom cursors in Flash,…
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 set there setting in Adobe Flash Media Live Encoder and YouTube for optimal video and audio quality.

762 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

20 Experts available now in Live!

Get 1:1 Help Now