I have
the default created_at date keep printing out as an MySQL format : 2015-06-12 09:01:26. I wanted to print it as my own way like 12/2/2017
, and other formats in the future.
I created
一个名为DataHelper.php
的文件,并将其存储在/app/Helpers/DateHelper.php
-它看起来像这样
<?php
namespace App\Helpers;
class DateHelper {
public static function dateFormat1($date) {
if ($date) {
$dt = new DateTime($date);
return $dt->format("m/d/y"); // 10/27/2014
}
}
}
I want
能在我的刀锋视野中称之为
DateHelper::dateFormat1($user->created_at)
我不知道下一步该怎么办.
What is the best practice to create a custom helper function in php Laravel 5?个