【发布时间】:2020-07-29 02:47:46
【问题描述】:
我正在使用 Axios 成功获取一些数据,我需要将这些数据存储到我的 Postgres 数据库中。
提取数据中的一个字段是pubDate 字段,其格式完全如下:
"Tue, 15 Apr 2020 20:01:30 +0000"
通读Moment docs,这似乎是这种“locale aware 'llll'”格式。
所以,我需要解析这个 pubDate 并将其格式化为默认的 Postgres 日期格式。然后 pubDate 看起来像这样:
"2020-04-14T20:01:30"
我一直在寻找这个过程很长一段时间,但找不到任何可行的方法。
我试过这个(没用),based on the String + Format from docs:
let date = moment(pubDate, 'llll').format();
我是 NodeJS 的新手,如果我搞砸了,抱歉。提前谢谢!
【问题讨论】:
标签: node.js postgresql date parsing momentjs