Set to first day of a month.

@param int|null $month
Null: month of this object.

@return Time

@throws \RuntimeException
Frozen.
@throws \InvalidArgumentException
Arg month not null or 1 through 12.
197679
public function setToFirstDayOfMonth(int $month = null) : Time
    {
        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }
        if ($month !== null) {
            if ($month < 1 || $month > 12) {
                throw new \InvalidArgumentException('Arg month[' . $month . '] isn\'t null or 1 through 12.');
            }
            $mnth = $month;
        }
        else {
            $mnth = (int) $this->format('m');
        }
        return $this->setDate(
            (int) $this->format('Y'),
            $mnth,
            1
        );
    }
795083
function get_first_date_last_month($m=1) {
    return $this->mdate($this->dateFormat, mktime(0, 0, 0, $this->mdate("m")-$m, 1, $this->mdate("Y")));
  }
424128
public static function GetDaysInMonth( int $year, int $month ) : int
   {

      $dt = new \DateTime();
      $dt->setDate( $year, $month, 2 );
      $dt->setTime( 0, 0, 2 );

      return \intval( $dt->format( 't' ) );

   }
1137063
public function setStartDate(int $day, int $month, int $year): self
    {
        $this->startDate = [$day, $month, $year];

        return $this;
    }
620006
public function setDate($year, $month, $day) : \DateTime /*self invariant*/
    {
        if ($this->frozen) {
            throw new \RuntimeException(get_class($this) . ' is read-only, frozen.');
        }
        return parent::setDate($year, $month, $day);
    }
1369263
public static function daysInMonth(int $month, int $year = null)
    {
        // Redefine vars
        $year   = ! empty($year) ? $year : (int) date('Y');

        if ($month < 1 or $month > 12) {
            return false;
        } elseif ($month == 2) {
            if ($year % 400 == 0 or ($year % 4 == 0 and $year % 100 != 0)) {
                return 29;
            }
        }

        $days_in_month = array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

        return $days_in_month[$month-1];
    }
621625
public void setMonth(int month)
  {
    if (month < 0 || DAYS_IN_MONTH.length <= month)
      return;

    _month = month;

    if (DAYS_IN_MONTH[month] <= _dayOfMonth)
      _dayOfMonth = DAYS_IN_MONTH[month] - 1;

    calculateJoin();
    calculateSplit(_localTimeOfEpoch);
  }
1033771
public static function of(int $month, int $day) : MonthDay
    {
        Field\MonthOfYear::check($month);
        Field\DayOfMonth::check($day, $month);

        return new MonthDay($month, $day);
    }
346554
public function byMonths(int $months): Date
    {
        return $this->monthTo($this->originalDate->month() + $months);
    }
1322201
def get_month_start(day=None):
    """"""
    day = add_timezone(day or datetime.date.today())
    return day.replace(day=1)
267489
public function sub_month($months)
    {
        $this->time = strtotime("-$months months", $this->time);
        $this->set_timestamp($this->time);
        
        return $this;
    }
155345
public function setDate($year, $month, $day)
    {
      // Validate
      self::validateDate($year, $month, $day);
      
      // Set internal year, month and day variables
      $this->year  = (int)$year;
      $this->month = (int)$month;
      $this->day   = (int)$day;
    }
839634
public function add_month($months)
    {
        $this->time = strtotime("+$months months", $this->time);
        $this->set_timestamp($this->time);
        
        return $this;
    }
805726
private static function get(int $value) : Month
    {
        static $values;

        if (! isset($values[$value])) {
            $values[$value] = new Month($value);
        }

        return $values[$value];
    }
513394
public function plusMonths(int $months) : ZonedDateTime
    {
        return ZonedDateTime::of($this->localDateTime->plusMonths($months), $this->timeZone);
    }
351573
public function compareTo(MonthDay $that) : int
    {
        if ($this->month < $that->month) {
            return -1;
        }
        if ($this->month > $that->month) {
            return 1;
        }
        if ($this->day < $that->day) {
            return -1;
        }
        if ($this->day > $that->day) {
            return 1;
        }

        return 0;
    }
1111941
public function setDate($year, $month, $day)
    {
        if($this->_date->setDate($year, $month, $day) === false) {
            return false;
        }

        return $this;
    }