src/LocalDateTime.php
public function withDay(int $day) : LocalDateTime
    {
        $date = $this->date->withDay($day);

        if ($date === $this->date) {
            return $this;
        }

        return new LocalDateTime($date, $this->time);
    }
public function withDay(int $day) : LocalDateTime
    {
        $date = $this->date->withDay($day);

        if ($date === $this->date) {
            return $this;
        }

        return new LocalDateTime($date, $this->time);
    }
public function withDay ( int $ day ) : LocalDateTime { $ date = $ this -> date -> withDay ( $ day ) ; if ( $ date === $ this -> date ) { return $ this ; } return new LocalDateTime ( $ date , $ this -> time ) ; }
Returns a copy of this LocalDateTime with the day-of-month altered.

If the resulting date is invalid, an exception is thrown.

@param int $day

@return LocalDateTime

@throws DateTimeException If the day is invalid for the current year and month.
Returns a copy of this LocalDateTime with the day - of - month altered .