Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract month, day from created_at column in Laravel?

Tags:

php

laravel

I want to display something like 01 June from created_at column. I tried doing something like this which I know, is quite dumb thing.

<span class="day">{{date('m', $new->created_at)}}</span>
like image 956
Azima Avatar asked Jul 17 '17 07:07

Azima


1 Answers

{{ $object->created_at->format('d M') }}

for day and month

{{ $object->created_at->format('M') }}

for only month

{{ $object->created_at->format('d') }}

for only day

$object referred to your passed variable from the controller to the blade

like image 180
Exprator Avatar answered Oct 03 '22 08:10

Exprator