November 10th, 2005

DateFormatter static class (update of Darron Schalls dateFormat.as)

I was at a ColdFusion 101 demo the other day at our Las Vegas User Group meeting and was watching Dave Byer use the CF Date formatting using masks. I had always thought that was something Flash needed built-in and I figured someone must have already built this. I started to look around and found a couple of things. The first was Darron Schall's dateFormat.as which was his port of ColdFusions's date formatting. I also found that ActionScript 3.0 will have the ability to format as well (via Macromedia Labs).

Darron's ActionScript was more promising because I can use it now, but its a bit dated with the #include , so I decided to take a few moments and update it to a static Class.

Anyhow.. Here is my modification on Darron's original script. The zip contains the class and a sample FLA. Kudo's to Darron for doing all the hard work!!

Download: DateFormatter Class

Actionscript:

  1. import DateFormatter;
  2. var testDate:Date = new Date();
  3. trace(DateFormatter.formatTo(testDate, "mm/dd/yyyy"));

2 Responses to “DateFormatter static class (update of Darron Schalls dateFormat.as)”