Last active
October 6, 2017 07:01
Revisions
-
necrophidia renamed this gist
Oct 6, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
necrophidia revised this gist
Oct 6, 2017 . No changes.There are no files selected for viewing
-
necrophidia created this gist
Oct 6, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,64 @@ <?php // Date Helper namespace App\Helpers; use Carbon\Carbon; class DateHelper { public static function parse_from_datepicker($date_raw) { $result = null; $date_arr = explode('/', $date_raw); if(count($date_arr) > 1){ $year = $date_arr[2]; $month = $date_arr[1]; $day = $date_arr[0]; $result = Carbon::create($year, $month, $day, 0, 0, 0); } return $result; } public static function datepicker($date) { if($date == null || $date == '00/00/0000') { return ''; } else { $parsed_date = Carbon::parse($date); $day = $parsed_date->day; if($day < 10) { $day = '0' . $day; } $month = $parsed_date->month; if($month < 10) { $month = '0' . $month; } return $day . '/' . $month . '/' . $parsed_date->year; } } public static function long_format($date) { if($date == null || $date == '00/00/0000') { return ''; } else { $parsed_date = Carbon::parse($date); return $parsed_date->format('d F Y'); } } public static function time_format($date) { if($date == null || $date == '00/00/0000') { return ''; } else { $parsed_date = Carbon::parse($date); return $parsed_date->format('d F Y H:i'); } } }