I had to do some date formatting for a project recently, and realised I missed the PHP Date function, so I recreated it in Actionscript 3. While I was doing it I noticed it’s been done a few times before, but there tend to be quite a few of the options missed out, or mistakes made, especially when it comes to the ISO stuff. The only function I couldn’t replicate properly was the Timezone identifier (e) as AS simply doesn’t have access to that information, so it could only be faked.
The example shows lovely slashes being used in the string but in the actual code you’ll have to escape (double) them or use a dollar symbol. Usage: DateUtils.date(‘c’, new Date(2008, 01, 01)); The date defaults to the (client side) date if it’s null.