Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/apache-flex/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Apache flex 在flex中将UTC时间转换为日期时间格式?_Apache Flex_Flex3 - Fatal编程技术网

Apache flex 在flex中将UTC时间转换为日期时间格式?

Apache flex 在flex中将UTC时间转换为日期时间格式?,apache-flex,flex3,Apache Flex,Flex3,如何在flex中将UTC时间转换为日期时间格式。我使用的是sdk 3.5。例如,UTC格式的当前日期时间为1309522586000(毫秒),我想将其转换为2011年7月1日星期五。我该怎么做 谢谢如果您使用的是从服务器检索的UNIX时间戳,首先必须将其乘以1000 这是因为UNIX时间戳以秒表示,而ActionScript时间戳以毫秒表示 您可以根据时间戳创建日期,如下所示: var myDate:Date = new Date(1309522586000); 接下来,创建一个formatD

如何在flex中将UTC时间转换为日期时间格式。我使用的是sdk 3.5。例如,UTC格式的当前日期时间为1309522586000(毫秒),我想将其转换为2011年7月1日星期五。我该怎么做


谢谢

如果您使用的是从服务器检索的UNIX时间戳,首先必须将其乘以1000

这是因为UNIX时间戳以秒表示,而ActionScript时间戳以毫秒表示

您可以根据时间戳创建日期,如下所示:

var myDate:Date = new Date(1309522586000);
接下来,创建一个formatDate函数,以myDate为参数调用该函数:

    <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和可能的格式的详细信息,请参见:

干杯