protected function get_time_range_weeks_number($starttime, $endtime) {
        if ($endtime <= $starttime) {
            throw new \coding_exception('End time timestamp should be greater than start time.');
        }

        $starttimedt = new \DateTime();
        $starttimedt->setTimestamp($starttime);
        $starttimedt->setTimezone(new \DateTimeZone('UTC'));
        $endtimedt = new \DateTime();
        $endtimedt->setTimestamp($endtime);
        $endtimedt->setTimezone(new \DateTimeZone('UTC'));

        $diff = $endtimedt->getTimestamp() - $starttimedt->getTimestamp();
        return $diff / WEEKSECS;
    }
protected function get_time_range_weeks_number($starttime, $endtime) {
        if ($endtime <= $starttime) {
            throw new \coding_exception('End time timestamp should be greater than start time.');
        }

        $starttimedt = new \DateTime();
        $starttimedt->setTimestamp($starttime);
        $starttimedt->setTimezone(new \DateTimeZone('UTC'));
        $endtimedt = new \DateTime();
        $endtimedt->setTimestamp($endtime);
        $endtimedt->setTimezone(new \DateTimeZone('UTC'));

        $diff = $endtimedt->getTimestamp() - $starttimedt->getTimestamp();
        return $diff / WEEKSECS;
    }
protected function get_time_range_weeks_number ( $ starttime , $ endtime ) { if ( $ endtime <= $ starttime ) { throw new \ coding_exception ( 'End time timestamp should be greater than start time.' ) ; } $ starttimedt = new \ DateTime ( ) ; $ starttimedt -> setTimestamp ( $ starttime ) ; $ starttimedt -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ endtimedt = new \ DateTime ( ) ; $ endtimedt -> setTimestamp ( $ endtime ) ; $ endtimedt -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; $ diff = $ endtimedt -> getTimestamp ( ) - $ starttimedt -> getTimestamp ( ) ; return $ diff / WEEKSECS ; }
Returns the number of weeks a time range contains.

Useful for calculations that depend on the time range duration. Note that it returns
a float, rounding the float may lead to inaccurate results.

@param int $starttime
@param int $endtime
@return float
Returns the number of weeks a time range contains .