src/Charcoal/Property/DateTimeProperty.php
public function storageVal($val)
    {
        $val = $this->dateTimeVal($val);

        if ($val instanceof DateTimeInterface) {
            return $val->format('Y-m-d H:i:s');
        } else {
            if ($this->allowNull()) {
                return null;
            } else {
                throw new Exception(
                    'Invalid date/time value. Must be a DateTimeInterface instance.'
                );
            }
        }
    }
public function storageVal($val)
    {
        $val = $this->dateTimeVal($val);

        if ($val instanceof DateTimeInterface) {
            return $val->format('Y-m-d H:i:s');
        } else {
            if ($this->allowNull()) {
                return null;
            } else {
                throw new Exception(
                    'Invalid date/time value. Must be a DateTimeInterface instance.'
                );
            }
        }
    }
public function storageVal ( $ val ) { $ val = $ this -> dateTimeVal ( $ val ) ; if ( $ val instanceof DateTimeInterface ) { return $ val -> format ( 'Y-m-d H:i:s' ) ; } else { if ( $ this -> allowNull ( ) ) { return null ; } else { throw new Exception ( 'Invalid date/time value. Must be a DateTimeInterface instance.' ) ; } } }
Convert `DateTime` to SQL-friendly string.

@param string|DateTime $val Optional. Value to convert to storage format.
@throws Exception If the date/time is invalid.
@see StorablePropertyTrait::storageVal()
@return string|null
Convert DateTime to SQL - friendly string .