PHP date in ActionScript

Written by Aaron Clinger on December 30th, 2008

When authoring CASA Lib we are often inspired by many other programming languages, frameworks and libraries. One of my favorite utilities in PHP is the date function. It is a great method for quickly formatting dates.

CASA Lib for AS2 and AS3 contain a DateUtil class. This class contains a formatDate method that acts almost identical to PHP’s date. The only change is that you use ^ to escape letters instead of \.

An example:

// Traces something like: "Tuesday the 30th of December 2008 10:24:13 AM"
trace(DateUtil.formatDate(new Date(), "l ^t^h^e dS ^of F Y h:i:s A"));

See DateUtil’s documentation for more information and options: