D
D
denn2021-09-20 06:54:57
WordPress
denn, 2021-09-20 06:54:57

How to change the default timezone for future WordPress Multisite sites?

The default is +3 UTC. Where is this value specified? Where to dig?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Brumer, 2021-09-20
@iDx

Where is this value specified? Where to dig?

Dig in this side

ссылка 1
ссылка 2
рабочий вариант:
add_action( 'wp_initialize_site', 'wpdocs_action_wp_initialize_site', 900 );
 
/**
 * Fires when a site's initialization routine should be executed.
 *
 * @param WP_Site $new_site New site object.
 */
function wpdocs_action_wp_initialize_site( WP_Site $new_site ) : void {
    switch_to_blog( $new_site->blog_id );
 
    update_option('gmt_offset','1');
    //update_option('gmt_offset','1.5');
    //update_option('gmt_offset','2');
    //update_option('gmt_offset','2.5');
    //update_option('gmt_offset','3'); //установлено по умолчанию
 
    restore_current_blog();
}

A
Artem Zolin, 2021-09-20
@artzolin

Where exactly do you want to change the time? Before getting the date, you can define a default timezone:

date_default_timezone_set( 'Europe/Samara' );
$date = date( 'd-m-Y H:i:s' );
var_dump( $date );

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question