No scheme:
var datestr:string = "2013-8-7 9:30:15";
var date:date = new Date ();
Date.time = Date.parse (DATESTR);//no
Trace (date.tostring ());
Why no:
As in the code, the Date.pare fails because the string format is required for parse
Several formats listed on the document:
mm/dd/yyyy HH:MM:SS TZD
HH:MM:SS TZD Day mon/dd/yyyy
Mon dd YYYY HH:MM:SS TZD Day
Mon dd HH:MM:SS TZD yyyy
day DD Mon HH:MM:SS TZD YYYY
mon/dd/yyyy HH:MM:SS TZD yyyy/mm/dd
HH:MM:SS TZD
So it's obvious that the no scheme:
var datestr:string = "2013-8-7 9:30:15";
is not in accordance with the format requirements
Yes scheme:
var datestr:string = "2013-8-7 9:30:15";
var date:date = new Date ();
Date.time = Date.parse (Convertdatestr (DATESTR));//yes, to use Convertdatestr method
//trace:wed 7 09:30:15 GMT+0 The
Trace (date.tostring ());
Convertdatestr () Method:
/**
* DATESTR format must be: Yyyy-mm-dd HH:MM:SS, such as: 2013-8-7 9:30:15;
* <listing>
* <font size= ' 2 ' >
*//e.g:
* var datestr:string = "2013-8-7 9:30:15";
* var date:date = new Date ();
* Date.time = Date.parse (Convertdatestr (DATESTR));
*//trace:wed 7 09:30:15 gmt+0800
* Trace (date.tostring ());
* </font>
* </listing>
* @author jave.lin
* @date 2013-8-7
* * */public
static function Convertdatestr (datestr:string): string{
var strarr:array = Datestr.split ("");
var fstr:string = "{0} {1} {2}";
Return Format (FSTR, (strarr[0] as String). Split ("-"). Join ("/"), Strarr[1], "GMT");
/** method In previous format article */public
static function format (str:string, ... args): string{for
(var i:int = 0; i< Args.length; i++) {
str = str.replace (new RegExp ("\\{" + i + "\ \}", "GM"), Args[i]);
}
return str;
}