src/Entity/Content.php
/**
     * All date/timestamps are created in the current local timezone by default.
     * Dates/timestamps must be stored in UTC in the database. This method converts
     * the local date to UTC.
     */
All date/timestamps are created in the current local timezone by default.
Dates/timestamps must be stored in UTC in the database. This method converts
the local date to UTC.
All date / timestamps are created in the current local timezone by default . Dates / timestamps must be stored in UTC in the database . This method converts the local date to UTC .
private function convertToUTCFromLocal(?\DateTime $dateTime): ?\DateTime
    {
        if ($dateTime instanceof \DateTime && $dateTime->getTimezone()->getName() !== 'UTC') {
            $utc = new DateTimeZone('UTC');
            $dateTime->setTimezone($utc);
        }
        return $dateTime;
    }
private function convertToUTCFromLocal ( ? \ DateTime $ dateTime ) : ? \ DateTime { if ( $ dateTime instanceof \ DateTime && $ dateTime -> getTimezone ( ) -> getName ( ) !== 'UTC' ) { $ utc = new DateTimeZone ( 'UTC' ) ; $ dateTime -> setTimezone ( $ utc ) ; } return $ dateTime ; }
All date/timestamps are created in the current local timezone by default.
All date / timestamps are created in the current local timezone by default .