作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想显示一个 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/
我是一名优秀的程序员,十分优秀!