ActionScript 3 Date

Did anyone alse than me wondered about Date.toString() output format in AS3? I mean what standard is it? It looks like something that adobe created for flash purpose and is not used anywhere else(?). According to the documentation AS3 output format for date is.

Day Mon Date HH:MM:SS TZD YYYY
Fri Sep 2 14:49:30 GMT+0200 2011

The format is not even compatible with JavaScript output format alert(new Date):

Fri Sep 02 2011 14:46:45 GMT+0200

There is a RFC standard for internet date RFC 3339 – Date and Time on the Internet: Timestamps

1996-12-19T16:39:57-08:00

… as well as ISO 8601 with more less the same format:

2011-09-02T12:57:00-02:00

So how come Adobe did not decided to use that format for default output? At least ActionScript Date class is smart enough to parse itself output into a valid date:

new Date("Fri Sep 2 14:49:30 GMT+0200 2011")

In case you would like to pass a date from a different language into ActionScript and you do not have timestamp value available (e.g. SimpleDateFormat in maven.build.timestamp.format), you can use following pattern to produce desired output:

EEE MMM d HH:mm:ss 'GMT'Z yyyy

Or you can use mx.rpc.xml.SchemaMarshaller.unmarshallDatetime() to convert ISO format into ActionScript Date.

1 comment so far

  1. Yop September 3, 2011 09:53

Leave a comment

Please be polite and on topic. Your e-mail will never be published.