tp5 查询本年、本月、本周的方法

tp5自带了一些查询的方法,今天说一下查询本年、本月以及本周的方法

whereTime()//此方法代替了between and 方法

  实际用法如下:

->whereTime('时间字段','year')//查询本年
->whereTime('时间字段','month')//查询本月
->whereTime('时间字段','week')//查询本周

  是不是很简单,那有人问了:查询去年,上个月以及上周的该怎么查呢?往下看:

->whereTime('时间字段','last year')//查询去年
->whereTime('时间字段','last month')//查询上个月月
->whereTime('时间字段','last week')//查询上周

  非常简单了,如果想在特定的时间内查询呢?往下看:

->whereTime('时间字段','between',['2017-1-1','2017-1-10'])

  End;

猜你喜欢

转载自www.cnblogs.com/dalaowang/p/11212364.html