gpt4 book ai didi

php - 如何在 ActionScript 3 中获取关于 MySQL 时间戳的时间?

转载 作者:行者123 更新时间:2023-11-30 23:18:08 29 4
gpt4 key购买 nike

我想显示一个 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.
}

最佳答案

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));

关于php - 如何在 ActionScript 3 中获取关于 MySQL 时间戳的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16688430/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com