duan4739 2014-09-04 10:07
浏览 430
已采纳

Laravel Eloquent检查日期是否与数据库中的日期不相等

How to make an Eloquent query that will check if date is not same as data as my database?

Currently what I tried is (my data in database is in timestamp, in Y-m-d H:i:s format, while my input only must in Y-m-d format)

$date = date('Y-m-d', strtotime($date));

//query something like this
Table::where('date', 'NOT LIKE', $date)->get();

Weirdly enough this does not work, any workaround?

  • 写回答

1条回答 默认 最新

  • doutao6380 2014-09-04 10:09
    关注

    Just add a "%" sign to the end of your date for the LIKE:

    $date = date('Y-m-d', strtotime($date)) . '%';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?