1

I want to show an ActionScript 3.0 Timer, with respect to a timestamp gotten from MySQL.

So suppose MySQL (PHP) returns a string like $my_birthday="2013-05-22 12:30:45" I got it from ActionScript by a URLLoader, and I want to show the timer like this:

My age:
01 hours 01 minutes 42 seconds

What function should I use in:

public function timerHandler(e:TimerEvent)
{
 log_textfield.text = String((new Date()).time) - my_birthday; // I need to convert the   Date().Time to unix timestamp I guess, and a function for time difference.
}
void
  • 1,876
  • 8
  • 24
  • 30

1 Answers1

0

This answer has a TimeSpan class that you may want to use. The code below should do what you need to get the TimeSpan where you can get the parts you need to display. I don't have Flash on this computer though to test, so your mileage may vary :)

// new Date() is allergic to dashes, it needs slashes.
my_birthday = my_birthday.replace('-', '/');
var sinceBirthday = TimeSpan.fromDates(new Date(), new Date(my_birthday));
Community
  • 1
  • 1
Joachim Isaksson
  • 176,943
  • 25
  • 281
  • 294