javascript - 如何在 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
解决方案
与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>
推荐阅读
- java - 用于异步处理的 Akka?
- c - 为什么 getline 在将 `-wrap=malloc` 传递给链接器时调用 glibc 的 malloc 而不是 __wrap_malloc?
- multithreading - 如何在 Rust 的 for 循环中添加线程?
- c# - MyClassLibrary.dll 看不到我的 Assembly.resources.dll
- c - AT-Commands ESP8266 01: AT+CIPSTART: How to fix response Link type Error / Can't connect with TCP
- excel - 从 7 个输入文件在一个 Excel 文件“报告”中提供多张工作表
- javascript - 如何在 Vuejs v-for 中迭代 GraphQL 聚合节点
- python - 如何在 pandas 中合并和格式化包含 int 数据类型的多个列?
- ruby-on-rails - 资产“上限生产部署”中的错误:预编译
- java - 尽管行数为 102,但使用 ProcessBuilder 执行 Linux 命令并从 reader.readLine() 获取 NULL