//TODO: delete it in version 9.9 or later, if no errors
/**
* Shortcode [wpbc_test_dates_functions] to test different dates functions on the server.
*
* @return void
*/
function wpbc_test_dates_functions() {
if ( wpbc_is_on_edit_page() ) {
return wpbc_get_preview_for_shortcode( 'wpbc_test_dates_functions', array() ); //FixIn: 9.9.0.39
}
ob_start();
ob_clean();
$server_zone = date_default_timezone_get();
debuge( array( 'init' => 'Default Timezones', 'server' => date_default_timezone_get(), 'wordpress' => wp_timezone()->getName(), 'wordpress - gmt_offset' => get_option( 'gmt_offset' ) ) );
// date_default_timezone_set( 'Europe/Oslo' );
// date_default_timezone_set( 'Europe/Amsterdam' );
// date_default_timezone_set( 'UTC' );
debuge( array( 'init' => 'After WPBC changed timezone to UTC', 'server' => date_default_timezone_get(), 'wordpress' => wp_timezone()->getName(), 'wordpress - gmt_offset' => get_option( 'gmt_offset' ) ) );
echo '
';
echo 'Test dates functions:
';
echo '
';
for ( $i = 0; $i < 366; $i ++ ) {
$ts = date( 'Y-m-d 16:00:01', strtotime( '+' . $i . ' days' ) );
$ts_arr = explode(' ',$ts);
$date_arr = array();
$date_arr['str'] = '+' . $i . ' days for ' . $ts_arr[0] . ' ' .$ts_arr[1] ;
$date_arr['server'] = date_default_timezone_get();
$date_arr['wordpress'] = wp_timezone()->getName();
$date_arr['loc_DT'] = wpbc_datetime_localized( $ts );
$date_arr['loc_D'] = wpbc_date_localized( $ts );
$date_arr['loc_T'] = wpbc_time_localized( $ts );
$date_arr['loc_D_param_D'] = wpbc_date_localized( $ts_arr[0] );
$date_arr['loc_T_param_T'] = wpbc_time_localized( $ts_arr[1] );
echo '' . var_export( $date_arr, 1 ) . '
';
}
date_default_timezone_set( $server_zone );
debuge( array( 'end' => 'Back to default previos timezone', 'server' => date_default_timezone_get(), 'wordpress' => wp_timezone_string() ) );
$content = ob_get_contents();
ob_end_clean();
return $content;
}
add_shortcode( 'wpbc_test_dates_functions', 'wpbc_test_dates_functions' );
//
//TODO: it's only for Debug: Comment it. //FixIn: 9.9.0.17
// date_default_timezone_set( 'America/Chicago' ); // For Debug in Booking Calendar - booking form, for shortcode [wpbc_test_dates_functions] this line can be commented