code: public function setMax($max)
      {
          if ($max instanceof DateTime) {
              $this->max = $max;
          } else {
              try {
                  $this->max = new DateTime($max);
              } catch (\Exception $e) {
                  $this->max = null;
              }
          }
  
          return $this;
      }
docs: Sets the "max" of the DateTimeRange.
  
  @param DateTime $max
  
  @return DateTimeRange