How to convert from string to date data type?

前端 未结 2 1821
谎友^
谎友^ 2020-12-03 05:55

\"enter

I am uploading data from a csv file to MongoDB. It is taking OrderDate

2条回答
  •  南方客
    南方客 (楼主)
    2020-12-03 06:20

    db.messages.find().forEach(function(doc) {
      doc.headers.datestamp = new Date(Date.parse(doc.headers.Date.toString())); 
      db.messages.save(doc);
      })
    

    This worked well to convert this sort of text: Tue, 14 Nov 2007 03:22:00 -0800 (PST)

    The text is from an email archive known as the Enron Corpus.

提交回复
热议问题