用于将日期转换为时间间隔的ActionScript函数

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用于将日期转换为时间间隔的ActionScript函数相关的知识,希望对你有一定的参考价值。

  1. private function formatDate(d:Date):String
  2. {
  3. var now:Date = new Date();
  4. var diff:Number = (now.time - d.time) / 1000; // convert to seconds
  5. if (diff < 60) // just posted
  6. {
  7. return "Just posted";
  8. }
  9. else if (diff < 3600) // n minutes ago
  10. {
  11. return (Math.round(diff / 60) + " minutes ago");
  12. }
  13. else if (diff < 86400) // n hours ago
  14. {
  15. return (Math.round(diff / 3600) + " hours ago");
  16. }
  17. else // n days ago
  18. {
  19. return (Math.round(diff / 86400) + " days ago");
  20. }
  21. }

以上是关于用于将日期转换为时间间隔的ActionScript函数的主要内容,如果未能解决你的问题,请参考以下文章

ActionScript 3 Flash:将毫秒转换为时间码

将数据帧从时间戳转换为时间间隔

vb 时间戳转换成时间

php怎么将指定日期转换为时间戳

将 TimeInterval 转换为字符串 <del>String 转换为时间间隔</del>

如何将日期转换为时间戳?