首页 > 解决方案 > 如何在 moment.js 中的特定毫秒后获取时间和日期?

问题描述

问题陈述: 我正在尝试使用 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

标签: javascriptdatetimetimemomentjs

解决方案


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>


推荐阅读