Carbon diffForHumans Date to DateTime Hi all.
I use this package to translate the Carbon dates in french : https://github.com/jenssegers/date
I have this date :
Date::parse( $value )->diffForHumans();
Now I want to store the date in the created_at field of the DB.
How can I modify the date to this format :
2016-03-04 09:31:13
The docs on that page have an example :
Methods such as parse and createFromFormat also support "reverse translations". When calling these methods with translated
input, it will try to translate it to English before passing it to DateTime:
$date = Date::createFromFormat('D d F Y', 'zaterdag 21 maart 2015');
Have you tried that?
I haven't saw that.
$date = Date::createFromFormat('D d F Y', 'zaterdag 21 maart 2015');
the format returned is something like this
Date {#260
+"date": "2015-08-27 11:48:30.000000"
+"timezone_type": 3
+"timezone": "UTC"
}
I try :
$date->date
but it's display an error
InvalidArgumentException in Carbon.php line 527:
Unknown getter 'date'
If you're just wanting to store it in the DB you can just do $created_at = $date; and laravel should take care of the details :-)
Please sign in or create an account to participate in this conversation.