- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我想知道该帐户创建以来已经过去了多长时间:
console.log('TIMEYWIMEY',req.user.createdAt, new Date(), new Date() - req.user.createdAt)
这会打印出 TIMEYWIMEY 2019-05-10T16:12:40.457Z 2019-07-26T16:05:58.142Z NaN
我不明白为什么它是 NaN,它们看起来都是日期,我认为你可以将它们相减。
最佳答案
根据我对问题的理解,您不应该从有效日期中获取毫秒差异,然后进行计算。
const d1 = createdAt.getTime();
const d2 = new Date().getTime();
const diff = d2 - d1;
然后根据差异转换为您需要的单位。例如:
const days = diff/1000*60*60*24;
关于node.js - 如何使用node.js获取mongodb中createAt以来的时间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57223625/
我使用 quickblox android 版本 2.1.1。我可以通过标签检索用户。它工作正常!但我想按标签检索用户并按 createAt 排序。我该怎么做?提前致谢! 最佳答案 QuickBlox
在 Express 框架中,我使用 Sequelize。我想选择注册的用户的名字和姓氏与createdAt字段匹配的特定日期。我的查询如下。 const userData = models.users
我有兴趣知道如何在使用java同步驱动程序时在mongo上拥有createdAt和updatedAt字段。 我知道如何在 Mongoose 中做到这一点 const SchemaName = new
我使用 Parse 作为后端,无法从 iOS 中的 PFObject 获取 createdAt 值,它对 PFUser 工作正常。 这很好用... NSDate *createdAt = [PFUse
这个问题在这里已经有了答案: Sequelize — use UNIX timestamp for DATE fields (3 个回答) 2年前关闭。 我是 Postgres 的新手。我通过 Seq
我是一名优秀的程序员,十分优秀!