| Conditions | 8 |
| Paths | 65 |
| Total Lines | 24 |
| Code Lines | 18 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 17 | public static function difference(PhpDateTime $time1, PhpDateTime $time2) |
||
| 18 | { |
||
| 19 | if ($time1 == $time2) { |
||
| 20 | return '0'; |
||
| 21 | } |
||
| 22 | |||
| 23 | $interval = $time1->diff($time2); |
||
| 24 | $years = $interval->format('%y'); |
||
| 25 | $months = $interval->format('%m'); |
||
| 26 | $days = $interval->format('%d'); |
||
| 27 | $hours = $interval->format('%h'); |
||
| 28 | $minutes = $interval->format('%i'); |
||
| 29 | $seconds = $interval->format('%s'); |
||
| 30 | |||
| 31 | $differenceString |
||
| 32 | = ($years ? $years . 'Y ' : '') |
||
| 33 | . ($months ? $months . 'M ' : '') |
||
| 34 | . ($days ? $days . 'd ' : '') |
||
| 35 | . ($hours ? $hours . 'h ' : '') |
||
| 36 | . ($minutes ? $minutes . 'm ' : '') |
||
| 37 | . ($seconds ? $seconds . 's ' : ''); |
||
| 38 | |||
| 39 | return trim($differenceString); |
||
| 40 | } |
||
| 41 | |||
| 55 |