【问题标题】:How to get time with respect to MySQL timestamp, in ActionScript 3?如何在 ActionScript 3 中获取关于 MySQL 时间戳的时间?
【发布时间】:2013-05-22 09:37:22
【问题描述】:

我想展示一个 ActionScript 3.0 Timer,与从 MySQL 获得的时间戳有关。

所以假设 MySQL (PHP) 返回一个类似 $my_birthday="2013-05-22 12:30:45" 的字符串 我是通过 URLLoader 从 ActionScript 获得的,我想像这样显示计时器:

My age:
01 hours 01 minutes 42 seconds

我应该使用什么函数:

public function timerHandler(e:TimerEvent)
{
 log_textfield.text = String((new Date()).time) - my_birthday; // I need to convert the   Date().Time to unix timestamp I guess, and a function for time difference.
}

【问题讨论】:

    标签: php mysql actionscript-3 timestamp


    【解决方案1】:

    This answer has a TimeSpan class that you may want to use。下面的代码应该可以完成获取 TimeSpan 所需的操作,您可以在其中获取需要显示的部分。我在这台电脑上没有 Flash 来测试,所以你的里程可能会有所不同:)

    // new Date() is allergic to dashes, it needs slashes.
    my_birthday = my_birthday.replace('-', '/');
    var sinceBirthday = TimeSpan.fromDates(new Date(), new Date(my_birthday));
    

    【讨论】:

      猜你喜欢
      • 2012-11-11
      • 1970-01-01
      • 2013-11-19
      • 2011-11-24
      • 2019-03-11
      • 2023-03-19
      • 2011-05-23
      • 1970-01-01
      • 2021-07-20
      相关资源
      最近更新 更多