mongoose返回数据时的格式日期
我使用mongoose返回数据时的格式日期,mongoose,Mongoose,我使用myModel.find() 结果: { _id : "5afe3beb6fb6b70bfffaff13", name: "test01", birthday: "Mon Jun 04 2018 14:56:46 GMT+0700 (+07)", }, { _id : "5afe3beb6fb6b70bfffafrr13", name: "test02", birthday: "Mon Jun 04 2018 1
myModel.find()代码>
结果:
{
_id : "5afe3beb6fb6b70bfffaff13",
name: "test01",
birthday: "Mon Jun 04 2018 14:56:46 GMT+0700 (+07)",
},
{
_id : "5afe3beb6fb6b70bfffafrr13",
name: "test02",
birthday: "Mon Jun 04 2018 14:56:46 GMT+0700 (+07)",
},
如何将“生日”字段从ISODate转换为Y-m-d
注意:不更新数据库
结果如下:
{
_id : "5afe3beb6fb6b70bfffaff13",
name: "test02",
birthday: "2018-06-06",
},
{
_id : "5afe3beb6fb6b70bfffafrr13",
name: "test02",
birthday: "2018-06-06",
},
谢谢你的时间 嘿@NeilLunn!我没有问题。你能再看一遍吗?你的运算符错了,我想你的意思是,但它不会转换“any”格式。它认为你的“字符串”是无效的。标记为该问题的不同副本。请不要再改变问题了。对不起,伙计。你的回答不符合我的要求。我搜索但没有结果。我需要像mongodb一样的结果