How to convert a carbon into string, to take the date only?

Almaida Jody picture Almaida Jody · Jun 5, 2018 · Viewed 23.9k times · Source

i have an collection like this

0 => array:4 [
  "so" => "SO-1"
  "product_name" => "EXTREME FORTE - BP"
  "created_at" => Carbon @1527481346 {#628
    date: 2018-05-28 04:22:26.0 UTC (+00:00)
  }
  "id" => "5b0b84027475aa1508002623"
]

how to take the "2018-05-28" only? can somebody help me to fix this problem? thank's anyway

Answer

Ziyad picture Ziyad · Jun 5, 2018
$collection_item->created_at->format('Y-m-d');