javascript unixtime 前面一分钟
您好,我正在将 unixtimestamp 传递给 javascript IF 语句,任何人都可以告诉我如何使用 javascript 生成未来一分钟的 unixtimestamp 。
任何帮助都会有所帮助。
谢谢
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
JavaScript Date 对象 有一个
getTime()
方法返回自 1970 年以来的毫秒数。要使其看起来像 UNIX 时间戳,您需要除以 1000 并四舍五入(使用Math.floor())
。添加 60 即可提前一分钟。The JavaScript Date object has a
getTime()
method that returns milliseconds since 1970. To make this look like a UNIX timestamp, you need to divide by 1000 and round (withMath.floor())
. Adding 60 get's your one minute ahead.UNIX 时间只是自 1970-01-01Z 以来的秒数。因此,只需添加 60,您就会在一分钟后获得时间戳。
UNIX time is just the number of seconds since 1970-01-01Z. So just add 60 you'll get a timestamp one minute later.
JavaScript
Date
对象的getTime
返回自 1970 年 1 月 1 日午夜以来的毫秒数。试试这个。
JavaScript
Date
object'sgetTime
returns the number of milliseconds since midnight Jan 1, 1970.Try this.
另一种以简单的方式获取 unix 时间戳(这是从 1970 年 1 月 1 日开始以秒为单位的时间)的方法是:
Another way to get the unix timestamp (this is time in seconds from 1/1/1970) in a simple way its: