src/Charcoal/Object/PublishableTrait.php
public function setPublishDate($time)
    {
        if ($time === null || $time === '') {
            $this->publishDate = null;
            return $this;
        }

        if (is_string($time)) {
            try {
                $time = new DateTime($time);
            } catch (Exception $e) {
                throw new UnexpectedValueException(sprintf(
                    'Invalid Publication Date: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if (!$time instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Publication Date must be a date/time string or an instance of DateTimeInterface'
            );
        }

        $this->publishDate = $time;

        return $this;
    }
public function setPublishDate($time)
    {
        if ($time === null || $time === '') {
            $this->publishDate = null;
            return $this;
        }

        if (is_string($time)) {
            try {
                $time = new DateTime($time);
            } catch (Exception $e) {
                throw new UnexpectedValueException(sprintf(
                    'Invalid Publication Date: %s',
                    $e->getMessage()
                ), $e->getCode(), $e);
            }
        }

        if (!$time instanceof DateTimeInterface) {
            throw new InvalidArgumentException(
                'Publication Date must be a date/time string or an instance of DateTimeInterface'
            );
        }

        $this->publishDate = $time;

        return $this;
    }
Set the object's publication date.

@param  string|DateTimeInterface|null $time The date/time value.
@throws UnexpectedValueException If the date/time value is invalid.
@throws InvalidArgumentException If the value is not a date/time instance.
@return PublishableInterface Chainable