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)) . '%';
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 乌班图ip地址配置及远程SSH
  • ¥15 怎么让点阵屏显示静态爱心,用keiluVision5写出让点阵屏显示静态爱心的代码,越快越好
  • ¥15 PSPICE制作一个加法器
  • ¥15 javaweb项目无法正常跳转
  • ¥15 VMBox虚拟机无法访问
  • ¥15 skd显示找不到头文件
  • ¥15 机器视觉中图片中长度与真实长度的关系
  • ¥15 fastreport table 怎么只让每页的最下面和最顶部有横线
  • ¥15 java 的protected权限 ,问题在注释里
  • ¥15 这个是哪里有问题啊?