JS取得此刻以及今天0点的UNIX时间戳

发表于 2021-01-15 07:19:29 (UTC+0)

示例代码如下

/**取得此刻时间戳 */
function get_now() {
    return parseInt(new Date().getTime() / 1000)
}

/**取得今天00:00:00的时间戳 */
function get_today() {
    return new Date(new Date().toDateString()).getTime() / 1000
}
0.135327s