2011-07-01 295 views

回答

1

如果您使用的是你是从你的服务器检索UNIX时间戳,首先你必须通过1000

这是因为UNIX时间戳以秒为单位,而ActionScript中的时间戳来表示它乘以以毫秒表示。

如下您可以从您的时间戳的日期:

var myDate:Date = new Date(1309522586000); 

接下来,你创建你指明MyDate调用作为参数formatDate功能:

<fx:Declarations> 
    <!-- Place non-visual elements (e.g., services, value objects) here --> 
    <mx:DateFormatter id="myDF" formatString="EEEE MMM D YYYY"/> 
</fx:Declarations> 
<fx:Script> 
    <![CDATA[ 
     private function formatDate(date:Date):void{ 
      trace(myDF.format(date)); 
     } 
    ]]> 
</fx:Script> 

请注意,我用的是dateformatter正确格式化日期。

更多DateFormatter和可能的格式在这里:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/formatters/DateFormatter.html

干杯