获取当前时间戳

395 阅读1分钟

获取当前时间戳

function getTime(type) {
    if (type === 'start') {
      return new Date().getTime() - 3600 * 1000 * 24 * 90
    } else {
      return new Date().getTime()
    }
}
console.log(getTime());

输出结果如图:
image.png

或者简单一句获取:

    const timestamp = new Date().getTime();
    console.log(timestamp);

输出:

image.png