logo
  • 教程列表
  • SO官方文檔
  • 時間戳
    • 高解析度時間戳
    • 低解析度時間戳
    • 以秒為單位獲取時間戳
    • 支援舊版瀏覽器
  1. StackOverflow 文件
  2. JavaScript 教程
  3. 時間戳
  4. 支援舊版瀏覽器

支援舊版瀏覽器

Created: November-22, 2018

在 Date.now() 不可用的舊瀏覽器中,請改用 (new Date()).getTime() :

t = (new Date()).getTime();

或者,要提供在舊版瀏覽器中使用的 Date.now() 函式,請使用此 polyfill :

if (!Date.now) {
  Date.now = function now() {
    return new Date().getTime();
  };
}
  • 以秒為單位獲取時間戳

Copyright © 2018. All right reserved

tastones.com 备案号:鲁ICP备18045372号-1

  • 關於本站
  • 免責聲明