rails - 使用时间来作为筛选项

访问量: 57

如下,记得结束时间,往往要算成第二天

7 @sign_tables = @sign_tables.where("sign_tables.created_at > ? ", params[:start_date]) if params[:start_date].present?
8 @sign_tables = @sign_tables.where("sign_tables.created_at < ? ", Date.strptime(params[:end_date], "%Y-%m-%d" ).tomorrow ) if ...

或者这样: (end_of_day ... )

.where("dish_orders.created_at >= ? AND dish_orders.created_at <= ?",
 params[:start_date].to_time.beginning_of_day, params[:end_date].to_time.end_of_day)

订阅/RSS Feed

Subscribe

分类/category