| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 2 | Features | 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)) { |
||
| 19 | return $date; |
||
| 20 | } |
||
| 21 | |||
| 22 | //Convert Carbon to Y-m-d |
||
| 23 | if ($date instanceof Carbon) { |
||
| 24 | return $date->format('Y-m-d'); |
||
| 25 | } |
||
| 26 | |||
| 27 | // sqlite Y-m-d H:i:s to Y-m-d |
||
| 28 | return Carbon::createFromFormat('Y-m-d H:i:s', $date)->format('Y-m-d'); |
||
| 29 | } |
||
| 30 | } |
||
| 31 |