Timezone is wrong when picking city (Copenhagen)

  1. … why the timezone is set to UTC instead of what the value I’ve set in the WordPress-settings-page

WordPress calculates offsets from UTC, therefore WordPress sets the default time zone to UTC and not the specific time zone you selected in the Settings → General admin page.

  1. Is it a big performance-hit, to leave my fixing line in the top of the functions-file: date_default_timezone_set ( 'Europe/Copenhagen' );

Maybe it’s not a big one, but even so, you should not change the default time zone.

Because if you do, then the following (critical issue) will be reported by the Site Health tool (wp-admin → Tools → Site Health):

PHP default timezone was changed after WordPress loading by a date_default_timezone_set() function call. This interferes with correct calculations of dates and times.

However, in certain cases, you may use date_default_timezone_set(), but you should restore the default time zone back to UTC once you’ve done with your code:

date_default_timezone_set ( 'Europe/Copenhagen' );
$datetime = new DateTime();
$datetime_str = $datetime->format( 'Y-m-d H:i:s' );
date_default_timezone_set( 'UTC' ); // restore it to UTC

But then, WordPress provides its own date/time functions which apply the time zone set via the admin settings page, e.g. wp_date() (or in the past, date_i18n()), so you could simply utilize those functions. E.g.

// Display current time in MySQL format using wp_date():
$datetime_str = wp_date( 'Y-m-d H:i:s' );

// Or you could just use current_time():
$datetime_str = current_time( 'mysql' );