Last active
June 6, 2016 00:07
-
-
Save atrakeur/9768077 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Defaut display of Carbon dates can be changed using the method | |
* This method have to be called BEFORE outputing any date to string | |
*/ | |
\Carbon\Carbon::setToStringFormat('d-m-Y H:i:s'); | |
/* | |
* Can be setup in your models constructors like this: | |
*/ | |
public function __construct() { | |
//Call the parent constructor | |
parent::__construct(); | |
//Set the format used by Carbon when converting date to string | |
\Carbon\Carbon::setToStringFormat('d-m-Y H:i:s'); | |
//all dates like 2014-03-25 17:37:54 look like 25-03-2014 17:37:54 now | |
} | |
/* | |
* Or in the start.php file like that: | |
*/ | |
/* | |
|-------------------------------------------------------------------------- | |
| Change the default date format | |
|-------------------------------------------------------------------------- | |
| | |
| Change date format output to french format | |
| | |
*/ | |
\Carbon\Carbon::setToStringFormat('d-m-Y H:i:s'); | |
/* | |
* It can even be set inside your filters.php (to conditionnaly format date based on url for example) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment