Published By - Rajendra Nagar

How to change the timestamp column's format in Laravel?

If you want to compare the timestamp column value with today's date then first you need to change the format of the date-time value to the current date

Rajendra Nagar

If you want to compare the timestamp column value with today's date then first you need to change the format of the date-time value to the current date

*For example - *

find today's date data from the database table and compare on the field created_at which is the timestamp column type.

$query->where(name, $name)->where(DB::raw("(DATE_FORMAT(date_time,'%Y-%m-%d'))"),
Carbon::now()->format('Y-m-d'));

Use DATE_FORMAT in DB::raw to convert the timestamp field into today's date and get data accordingly from the database.