src/Entity/Content.php
/**
     * All date/timestamps are stored in the database in UTC. When retrieving
     * them, we get the timestamp as-is in the DB with the current local
     * timezone slapped onto it. This method converts it back to UTC, and
     * then re-applies the current local timezone to it.
     */
All date/timestamps are stored in the database in UTC. When retrieving
them, we get the timestamp as-is in the DB with the current local
timezone slapped onto it. This method converts it back to UTC, and
then re-applies the current local timezone to it.
All date / timestamps are stored in the database in UTC . When retrieving them we get the timestamp as - is in the DB with the current local timezone slapped onto it . This method converts it back to UTC and then re - applies the current local timezone to it .
private function convertToLocalFromDatabase(?\DateTime $dateTime): ?\DateTime
    {
        if (! $dateTime) {
            return null;
        }
        $dateTimeUTC = new \DateTime($dateTime->format('Y-m-d H:i:s'), new \DateTimeZone('UTC'));
        return $dateTimeUTC->setTimezone($dateTime->getTimezone());
    }
private function convertToLocalFromDatabase ( ? \ DateTime $ dateTime ) : ? \ DateTime { if ( ! $ dateTime ) { return null ; } $ dateTimeUTC = new \ DateTime ( $ dateTime -> format ( 'Y-m-d H:i:s' ) , new \ DateTimeZone ( 'UTC' ) ) ; return $ dateTimeUTC -> setTimezone ( $ dateTime -> getTimezone ( ) ) ; }
All date/timestamps are stored in the database in UTC.
All date / timestamps are stored in the database in UTC .