I've found that ActionScript will correctly format a date
given a string like ''1962-06-14'', but it cannot construct a Date
object from the same string. This seems like a defect in the Date
class.
For example:
var df:DateFormatter = new DateFormatter();
df.formatString = ''MM/DD/YYYY'';
trace( df.format(''1962-06-14'') ); %26gt;%26gt;%26gt;%26gt;%26gt;
06/14/1962
var d:Date = new Date(''1962-06-14'');
trace( d ); %26gt;%26gt;%26gt;%26gt;%26gt;%26gt; Invalid Date
This is important because I'm getting my data from a Rails
application. The default format Rails uses when putting date values
into XML is ''yyyy-mm-dd''.Defect constructing date from string
No you can't create a date like this.
You must convert it by using the split method of String
object into an array then you create your date like the following
example
return new Date(arr[0], arr[1], arr[2]);
Subscribe to:
Post Comments
(Atom)
No comments:
Post a Comment