简体   繁体   English

在 JavaScript 中获取日期值以在 MongoDB 中发送的最佳方法是什么?

[英]What is The Best way to get date value in JavaScript to send in MongoDB.?

I want to get the date value from React and want to send it to MongoDB using Node.js. What is the best way to get the date value that is suitable for sending to MongoDB.?我想从 React 获取日期值并想使用 Node.js 将其发送到 MongoDB。获取适合发送到 MongoDB 的日期值的最佳方法是什么?

May be like that:可能是这样的:

const tourSchema = mongoose.Schema({
      title: String,
      description: String,
      name: String,
      creator: String,
      tags: [String],
      imageFile: String,
      **createdAt: {
        type: Date,
        default: new Date(),
      },**
      likes: {
        type: [String],
        default: [],
      },
    });

ignore **忽略 **

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将日期从客户端(Javascript)发送到WebApi的最佳方法是什么 - What is the best way to send Date from client(Javascript) to WebApi 在 vanilla JavaScript 中向服务器发送 GET 请求的最佳方式是什么? - What is the best way to send a GET request to the server in vanilla JavaScript? 在javascript对象中,获取值属性的最佳方法是什么? - in a javascript object, what's best way to get the attribute of a value? 使用JavaScript获取和设置单个cookie值的“最佳”方法是什么? - What is the “best” way to get and set a single cookie value using JavaScript 在 JavaScript 中确定日期是否为今天的最佳方法是什么? - What is the best way to determine if a date is today in JavaScript? 将 JavaScript 日期初始化为午夜的最佳方法是什么? - What is the best way to initialize a JavaScript Date to midnight? API响应在mongoDb中发送问题。 - API response send issue in mongoDb. 使用GET将JavaScript数组发送到PHP脚本的最佳方法是什么? - What's the best way to send JavaScript array to PHP script using GET? 在JavaScript中按名称获取cookie的最佳方法是什么? - What is the best way to get a cookie by name in JavaScript? 在JavaScript中获取随机数的最佳方法是什么 - What is the best way to get random number in JavaScript
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM