Fix plugin conflict with WooCommerce / date_default_timezone_set ('Asia/Riyadh')
Budget: $10 – $30 USD
WordPress core requires the timezone in PHP to be UTC. Several features are dependent on this, and will break if the timezone is adjusted. So we need our plugin to retrieve order details in 'Asia/Riyadh' without changing the default timezone
From
add_action('wp_loaded', 'time_zone_function');
function time_zone_function(){
date_default_timezone_set ('Asia/Riyadh');
}
To:
retrieve time as Unix timestamp or DateTimeImmutable object:
time()
current_datetime()
get_post_datetime()
get_post_timestamp()
Or
use DateTimeZone and DateTimeImmutable objects (with wp_date() for localization),
From
add_action('wp_loaded', 'time_zone_function');
function time_zone_function(){
date_default_timezone_set ('Asia/Riyadh');
}
To:
retrieve time as Unix timestamp or DateTimeImmutable object:
time()
current_datetime()
get_post_datetime()
get_post_timestamp()
Or
use DateTimeZone and DateTimeImmutable objects (with wp_date() for localization),