code: public function dayOfYear()
      {
          $k = $this->isLeapYear() ? 1 : 2;
          $n = intval(275 * (int)$this->month / 9) -
            $k * intval(((int)$this->month + 9) / 12) +
            (int)$this->day - 30;
  
          return (int)$n;
      }
docs: Returns the day of the year number, 0-356 or 0-366 for leap year
  
  @return int