Strange behavior when converting date

I'm working with a date string that looks like this

Wed Nov 30 22:51:20 +0000 2011

I'm trying to convert it to type Date in Actionscript. When I do this, I get the date in 1969.

asDate = new Date(asString); //or new Date(asString as String);

But if I create a class with static function that just does exactly the same thing, I get the real date in 2011.

asDate = MyDate.retDate(asString);

public class MyDate {
  public static function retDate(asString:String):Date {
     return new Date(asString);

The class way works, but the simple way doesn't, even though what I'm doing in the class is exactly the same line as when I try to do it without the class. I thought maybe it has to do with the type, so I tried new Date(asString as String); but this also give the 1969 date.


Did you try parsing the date using the static function Date::parse()? For example:

var date:Date = Date.parse(asString);

Need Your Help

NSString and UITapGestureRecognizer as method arguments

objective-c cocoa-touch nsstring uitapgesturerecognizer

I am wondering how to use a NSString and a UITapGestureRecoginzer as method arguments in Xcode.

Auto increment function, Oracle PL/SQL

sql oracle function arguments auto-increment

I have a number of triggers which do various things, but at the top of all of those which have unique integer primary keys, I need them to auto increment. The code currently looks as follows: