2011-07-01 372 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

乾杯