获取unix时间戳在PHP5和ActionScript3的毫秒 [英] Getting unix timestamp in milliseconds in PHP5 and Actionscript3

查看:237
本文介绍了获取unix时间戳在PHP5和ActionScript3的毫秒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在ActionScript中,Unix时间戳以毫秒为获得这样的:

In Actionscript, the Unix timestamp in milliseconds is obtainable like this:

public static function getTimeStamp():uint
        {
            var now:Date = new Date();
            return now.getTime();
        }

在文档中明确规定了以下内容:

The doc clearly states the following:

的getTime():Number返回数量   毫秒自午夜1月1日,   1970年,通用时间,对于一个日期   对象。

getTime():Number Returns the number of milliseconds since midnight January 1, 1970, universal time, for a Date object.

当我跟踪它,它返回如下:

When I trace it, it returns the following:

824655597

所以,1000分之824655597/ 60/60/24/365 = 0.02年。 这显然​​是不正确的,因为它应该是在39年。

So, 824655597 / 1000 / 60 / 60 / 24 / 365 = 0.02 years. This is obviously not correct, as it should be around 39 years.

问题1:什么是错在这里

Question #1: What's wrong here?

现在,到PHP的一部分:我试图让以毫秒为单位的时间戳那里。该 microtime中()函数返回一个字符串(0.29207800 1246365903)或浮点数(1246365134.01),根据给定的参数。因为我认为时间戳很容易,我要做到这一点我自己。但现在,我已经尝试过,发现这个浮动,并结合了我在Actionscript中的问题我真的不知道。

Now, onto the PHP part: I'm trying to get the timestamp in milliseconds there as well. The microtime() function returns either a string (0.29207800 1246365903) or a float (1246365134.01), depending on the given argument. Because I thought timestamps were easy, I was going to do this myself. But now that I have tried and noticed this float, and combine that with my problems in Actionscript I really have no clue.

问题2:我应该怎么让它返回一个Unix时间戳毫秒数

Question #2: how should I make it returns the amount of milliseconds in a Unix timestamp?

时间戳应该是那么容易,我可能失去了一些东西......很抱歉。先谢谢了。

Timestamps should be so easy, I'm probably missing something.. sorry about that. Thanks in advance.

EDIT1:由本人回答的第一个问题。见下文。
EDIT2:回答第二个我自己的问题也是如此。见下文。不能接受48小时内答复。

Answered the first question by myself. See below.
Answered second question by myself as well. See below. Can't accept answer within 48 hours.

推荐答案

有关的ActionScript3,新的Date()。的getTime()应该工作。

For actionscript3, new Date().getTime() should work.

在PHP中,你可以简单地调用时间()获得的时间过去了,1970年1月1日00:00:00 GMT在秒。如果你想毫秒只是做(时间()* 1000)

In PHP you can simply call time() to get the time passed since January 1 1970 00:00:00 GMT in seconds. If you want milliseconds just do (time()*1000).

如果您使用 microtime中() 1000乘以第二部分获得毫秒。乘的第一部分1000得到毫秒一轮。然后添加两个数字加在一起。瞧。

If you use microtime() multiply the second part with 1000 to get milliseconds. Multiply the first part with 1000 to get the milliseconds and round that. Then add the two numbers together. Voilá.

这篇关于获取unix时间戳在PHP5和ActionScript3的毫秒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆