问题陈述: 我正在尝试使用moment.js在一定毫秒后获取时间和日期 示例:
const expiresIn = 30000 // milliseconds
const issuedAt = moment().toString();
const expiresAt = // I need to get the time and date after "expiresIn"(milliseconds) so i can set the "expiresAt" as time and date
答案 0 :(得分:1)
使用setTimeout()
const expiresIn = 3000 // milliseconds
setTimeout(function(){
console.log(moment().toString())
},expiresIn)
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.24.0/moment.min.js"></script>