Q:

Laravel where dates by specific format

In DB Col Name('publish') varchar format d/m/Y  for Example  30/1/2020
when try to get dates less than 30/1/2020 get any date less than days  

for example

->where('publish','<','30/01/2020')

29/2/2020  less than 30/1/2020 so i get any date under 30 by day not month or year

A:

on your Eloquent model define an accessor to retrive publish as carbon object
public function getPublishAttribute($date)
{
    return Carbon::parse($date)->format('d/m/Y');
}

now on your controller compare both date as below
->where('publish','<',Carbon::parse('30/01/2020'))

hope it helps!

