Returns a copy of this LocalDateTime with the specified period in years added.

@param int $years

@return LocalDateTime

@throws DateTimeException If the resulting year is out of range.
14736
public function plusYears(int $years) : LocalDateTime
    {
        if ($years === 0) {
            return $this;
        }

        return new LocalDateTime($this->date->plusYears($years), $this->time);
    }
900347
public static Date addYears(final Date date, final int addYears)
	{
		final Calendar dateOnCalendar = Calendar.getInstance();
		dateOnCalendar.setTime(date);
		dateOnCalendar.add(Calendar.YEAR, addYears);
		return dateOnCalendar.getTime();
	}
663453
public static String getDate(int days, int months, int years, String format) {
        return getDate(days, months, years, format, Locale.ENGLISH);
    }
571804
public function plusMonths(int $months) : LocalDate
    {
        $month = $this->month + $months - 1;

        $yearDiff = Math::floorDiv($month, 12);
        $month = Math::floorMod($month, 12) + 1;

        $year = $this->year + $yearDiff;

        return $this->resolvePreviousValid($year, $month, $this->day);
    }
1192668
public function addMonths($months)
    {
        if($months==0){
            return new DateTime($this->_time);
        }
        $year=$this->getYear();
        $month=$this->getMonth();
        $day=$this->getDay();
        if($months>0){
            $addYears=floor($months/12);
            $addMonths=$months%12;
            while ($addMonths+$month>12){
                $addYears++;
                $addMonths-=12;
            }
            $str=strval($year+$addYears)."-".strval($addMonths+$month)."-01";
            $lastDay = date("t",strtotime($str));//当月的最后一天
            if($day>$lastDay){
                $day=$lastDay;
            }
            $str=strval($year+$addYears)."-".strval($addMonths+$month)."-".$day." ".date("H:i:s",$this->_time);
            return new DateTime(strtotime($str));
        }else{
            $months=abs($months);
            $addYears=floor($months/12);
            $addMonths=$months%12;
            while($month-$addMonths<=0){
                $addYears++;
                $addMonths-=12;
            }
            $str=strval($year-$addYears)."-".strval($month-$addMonths)."-01";
            $lastDay = date("t",strtotime($str));//当月的最后一天
            if($day>$lastDay){
                $day=$lastDay;
            }
            $str=strval($year-$addYears)."-".strval($month-$addMonths)."-".$day." ".date("H:i:s",$this->_time);
            return new DateTime(strtotime($str));
        }
    }
761240
public static function ofYearDay(int $year, int $dayOfYear) : LocalDate
    {
        Field\Year::check($year);
        Field\DayOfYear::check($dayOfYear, $year);

        $isLeap = Field\Year::isLeap($year);

        $monthOfYear = Month::of(\intdiv($dayOfYear - 1, 31) + 1);
        $monthEnd = $monthOfYear->getFirstDayOfYear($isLeap) + $monthOfYear->getLength($isLeap) - 1;

        if ($dayOfYear > $monthEnd) {
            $monthOfYear = $monthOfYear->plus(1);
        }

        $dayOfMonth = $dayOfYear - $monthOfYear->getFirstDayOfYear($isLeap) + 1;

        return LocalDate::of($year, $monthOfYear->getValue(), $dayOfMonth);
    }
517934
public static function calculateYearsAgo(DateDiffRequest $request)
    {
        return new DateDiffResult($request, self::YEARS_AGO, $request->getInterval()->y);
    }
278511
public static function from(DateTimeParseResult $result) : LocalDateTime
    {
        return new LocalDateTime(
            LocalDate::from($result),
            LocalTime::from($result)
        );
    }
1052094
public static function fromDateTime(\DateTimeInterface $dateTime) : LocalDateTime
    {
        return new LocalDateTime(
            LocalDate::fromDateTime($dateTime),
            LocalTime::fromDateTime($dateTime)
        );
    }
265766
public function firstAirDateYear($year)
    {
        if ($year instanceof \DateTime) {
            $year = $year->format('Y');
        }

        $this->set('first_air_date_year', (int) $year);

        return $this;
    }
436941
public function withDays(int $days) : Period
    {
        if ($days === $this->days) {
            return $this;
        }

        return new Period($this->years, $this->months, $days);
    }
459135
public static function easterDate($year)
    {
        if ($year < 1970 || $year > 2037) {
            return trigger_error('This function is only valid for years between 1970 and 2037 inclusive', E_USER_WARNING);
        }

        $days = self::$gregorian_calendar->easterDays($year);

        // Calculate time-zone offset
        $date_time      = new \DateTime('now', new \DateTimeZone(date_default_timezone_get()));
        $offset_seconds = (int) $date_time->format('Z');

        if ($days < 11) {
            return self::jdtounix(self::$gregorian_calendar->ymdToJd($year, 3, $days + 21)) - $offset_seconds;
        } else {
            return self::jdtounix(self::$gregorian_calendar->ymdToJd($year, 4, $days - 10)) - $offset_seconds;
        }
    }
846447
public function withYear(int $year): DateTime
    {
        return new static(
            Date::create($year, $this->month(), $this->day()),
            $this->time(),
            $this->timezone()
        );
    }
1322368
public function minusMonths(int $months) : LocalDateTime
    {
        if ($months === 0) {
            return $this;
        }

        return new LocalDateTime($this->date->minusMonths($months), $this->time);
    }
609812
public function getIsoYear(): Period
    {
        $year = (int) $this->format('o');
        $datepoint = $this->setTime(0, 0);

        return new Period($datepoint->setISODate($year, 1, 1), $datepoint->setISODate(++$year, 1, 1));
    }
322024
public function withYear(int $year) : YearMonth
    {
        if ($year === $this->year) {
            return $this;
        }

        Field\Year::check($year);

        return new YearMonth($year, $this->month);
    }
855621
public static function getYearsAgo($ago, $endDateTime = null)
    {
        return static::getDateTimeRange(
            Carbon::now()->subYears($ago)->startOfYear(),
            $endDateTime ?: Carbon::now()->subYears($ago)->endOfYear()
        );
    }