In my Laravel project I have a MySQL database table with the following column:
| requested_at |
2018-02-03 12:00:00
2018-03-03 11:00:00
I want to get all items from this column where the timestamp (requested_at) is older than 60 days:
$now = Carbon::now ();
$60days = DB::table('exampletable')->where('requested_at', '=', $now->subDays(60))->get();
For my following code I need to format the Date format from my column requested at.
I only want to get the date like this 2018-03-03 without the time.
I play around with some carbon methods but It didn't work at all:
$format60 = Carbon::createFromFormat('Y-m-d', $60days);

$60daysis invalid, variables must start with an underscore OR a letter. As for the Carbon part it should look something like this,Carbon::createFromFormat('Y-m-d', $days60['FIELD THAT HAS YOUR TIME VALUE']);- note I changed your variable name.