1

在下面给出的代码中$allZip["assigned_date"]具有 value 2016-07-27 18:12:26。当我尝试将它与created_at也是时间戳字段的字段进行比较时,结果是一个空集合。

$filtered_datas = $datas->filter(function ($data) use($allZip) {
    return $data->zip == $allZip["zip"] && $data->created_at < $allZip["assigned_date"];
});

数据库中存在zip字段匹配值 from$allZip["zip"]created_at字段值匹配的数据2016-07-19 18:12:26。所以它应该返回集合中的一项,但返回一个空集合。为什么?

4

1 回答 1

-1

确保您的所有日期都是DateTimeCarbon实例,而不是字符串。否则,比较运算符不应按您的预期工作。

于 2016-07-28T19:11:02.853 回答