Laravel 4 carbon date format change only once -


Hello I'm using laravel 4 for an app page, I like the carbon date function, but I like the date format Problems with I have a date format like this:

  dd / mm / yyyy  

and I use it:

  \ Carbon \ Carbon :: createFromTimeStamp (strtotime (Eth :: user () -> created_at) -> diffForHumans ()  

to show how old it is But it works fine in date format

  yyy-mm-dd  

I can change the date format only once and every time No.

You can try this:

  $ date = Auth :: user ); & Gt; Created on; \ Carbon \ Carbon :: createFromFormat ('d / m / y', $ date) -> diffForHumans ();  

In addition to this You can try it (if you want to use the createFromTimeStamp method):

  $ date = str_replace ('/', '-', Ath :: User () - & gt; created_at); \ carbon \ carbon :: createFromTimeStamp (strtotime ($ date)) - & gt; DiffForHumans ();  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -