【问题标题】:date comparison in where clause : in mongodb with lumenwhere 子句中的日期比较:在 mongodb 中与流明
【发布时间】:2019-04-19 14:20:08
【问题描述】:

在 mongodb 中日期以以下格式存储,

"delivery_at" : {
        "date" : "2018-11-15 13:41:38.000000", 
        "timezone_type" : NumberInt(1), 
        "timezone" : "+00:00"
    }, 

在我的搜索字符串中,日期传递如下,

$data = "2018-11-16";

我的查询如下 mongodb,

 $query->where("delivery_at", ">=", new \DateTime($data ));

但它没有给我预期的结果与 mongodb

【问题讨论】:

标签: php mongodb laravel lumen


【解决方案1】:

Laravel 的 Eloquent 支持 Carbon/DateTime 对象
如需更多参考,您可以访问 How to compare date with mongodb iso date in laravel mongodb eloquent query? 希望对你有帮助

【讨论】:

  • 我使用了 Carbon::createFromDate(2015, 10, 1),但它不适合我
  • 它是否给出任何错误或输出是与您的实施有关的意外更新问题
猜你喜欢
  • 2017-09-16
  • 1970-01-01
  • 2012-01-02
  • 1970-01-01
  • 1970-01-01
  • 2021-10-09
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多