<?php

namespace MGModule\DNSManager2\mgLibs\custom\helpers;

class TimeDiffHelper {
    public static function getExtendedDataInterval(\DateInterval $diff) {      
        $diff->years = floor($diff->days / 365.25);
        $diff->months = floor($diff->days / 30);
        $diff->hours = $diff->days * 24 + $diff->h;
        $diff->minutes = $diff->hours * 60 + $diff->i;
        $diff->seconds = $diff->minutes * 60 + $diff->s;
        return $diff;
    }
    
    public static function diff($date1, $date2 = '') {
        $date1 = new \DateTime($date1);
        return self::getExtendedDataInterval($date1->diff(new \DateTime($date2)));
    }
}