在前端获取UTC时间戳的方法

in #cn-dev4 years ago (edited)

image.png

function getUtcTimestamp() {
    const now = new Date();
    const utcTimestamp = Date.UTC(
        now.getUTCFullYear(),
        now.getUTCMonth(),
        now.getUTCDate(),
        now.getUTCHours(),
        now.getUTCMinutes(),
        now.getUTCSeconds(),
        now.getUTCMilliseconds()
    );
    return `${parseInt(utcTimestamp / 1000, 10)}`;
}

Coin Marketplace

STEEM 0.19
TRX 0.15
JST 0.029
BTC 63550.59
ETH 2644.53
USDT 1.00
SBD 2.81