Hello all, I've developed a rather simple date parser which reads in a string from SQL ('12/10/2009') and converts into a flex date. Here is the function
public function parseDateFunc(s:String):Date
var a:Array = s.split("/");
var newDate:Date = new Date(s);
newDate.fullYear = a; // YEAR
newDate.month = a; // MONTH
newDate.date = a; // DAY
For some unknown, strange reason this is causing the month to be incremented by 1 month, the year and date is obsoutely as it is in SQL. I've tried not using the date parser and it comes into flex as it shows in SQL.
Anyone have any ideas?
The month is zero-indexed in Flex. E.g., to create a Date object for January 1, 2000, you'd type new Date(2000, 0, 1). This is probably why you're seeing the offset.
If you check the documentation, I believe the month is 0 based, not 1 based, so the months are 0-11, not 1-12.
Ok thanks guys - this is the reason. Sounds counter intuititive to me. Never mind, fixed now.