node.js - 如何在没有时间戳的mongodb集合中保存文档
问题描述
请看看这个日期功能
let tomorrowDate = new Date();
console.log('tomorrowDate',tomorrowDate ) // it returns D-1th date
tomorrowDate = tomorrowDate.setDate(tomorrowDate.getDate() + 1);
tomorrowDate = new Date(tomorrowDate);
tomorrowDate = tomorrowDate.toISOString().split("T")[0];
tomorrowDate = new Date(tomorrowDate);
如果我明天不重新启动我的开发服务器在 00:00 时选择 D-1 日,我将面临此代码的问题,假设今天是 2020 年 3 月 11 日 00:00 时新日期应该是 2020-03- 12T...Z 但在 00:00 时 new Date() 返回 2020-03-11 为什么会这样???如果我想删除时间戳并且只想保存日期,我尝试拆分 T 但此函数仍将 T00:00:00.000Z 添加为时间戳。
解决方案
推荐阅读
- python - 托管在不同服务器上的两个 Python 应用程序如何通信?
- ruby - Ruby 解析无效的 JSON
- json - 如何在 PostgreSQL 中解析这个 JSON 字段?
- r - R在使用带有xlim的基本图时如何自动调整y轴
- javascript - 变量和 if 语句在 Javascript 中产生错误
- java - 在带有 appengine-maven-plugin 的 appengine 上的多模块 maven java 项目中部署期间跳过某些模块
- javascript - 如何获取特定列标题过滤器的 dataFiltered-Callback?
- r - RStudio 警告消息:(来自记忆):as_tibble 正在改变..请使用
- javascript - 单击向下/向上键在 ul 元素内滚动 - React
- api - 如何在正文请求中将用户凭据传递给被邀请人而不是作为查询参数