Skip to content

JavaScript获取秒级时间戳方法 #41

@yihan12

Description

@yihan12

思路分析

使用 Math.floor(Date.now() / 1000) 获取当前秒级时间戳

使用 new Date().getTime() / 1000 然后取整

实时更新时间戳显示

 // 获取当前秒级时间戳
function getTimestamp() {
    return Math.floor(Date.now() / 1000);
}

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions