我正在努力创造一个我可以轻松与他人联系起来的时间价值。
var created = Date.now() * 1000
var day_ago = Date.now() * 1000 - 24*60*60
if(created > day_ago){console.log('it was created in the last day')}
这似乎无法正常工作,任何人都知道我做错了什么
我正在努力创造一个我可以轻松与他人联系起来的时间价值。
var created = Date.now() * 1000
var day_ago = Date.now() * 1000 - 24*60*60
if(created > day_ago){console.log('it was created in the last day')}
这似乎无法正常工作,任何人都知道我做错了什么
Date.now() 将返回除以 1000 的毫秒数,以秒为单位进行转换。
var created = Date.now() / 1000
var day_ago = Date.now()/ 1000 - 24*60*60
if(created > day_ago){console.log('it was created in the last day')}
您必须除以 1000,而不是相乘
var created = Date.now() / 1000
var day_ago = Date.now() / 1000 - 24*60*60
if(created > day_ago){console.log('it was created in the last day')}