Conditions | 3 |
Paths | 3 |
Total Lines | 11 |
Code Lines | 4 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
15 | public function dateFormat($date) |
||
16 | { |
||
17 | // Already Y-m-d |
||
18 | if (preg_match('/^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$/', $date)) return $date; |
||
19 | |||
20 | //Convert Carbon to Y-m-d |
||
21 | if ($date instanceof Carbon) return $date->format('Y-m-d'); |
||
22 | |||
23 | // sqlite Y-m-d H:i:s to Y-m-d |
||
24 | return Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d'); |
||
25 | } |
||
26 | } |