Last active
August 16, 2021 07:10
-
-
Save PluginHive/7fb8f48c6b6f1d30d33ad50cb1a37c2b to your computer and use it in GitHub Desktop.
Snippet to define a custom date format to show Estimated delivery using the PluginHive's Estimated Delivery Date plugin for WooCommerce : https://www.pluginhive.com/product/estimated-delivery-date-plugin-woocommerce/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Snippet to define a custom date format to show Estimated Delivery Date | |
* Created at : 16 Aug 2021 | |
* PluginHive Plugins : Estimated Delivery Date Plugin For WooCommerce | |
* Gist Link : https://gist.github.com/PluginHive/7fb8f48c6b6f1d30d33ad50cb1a37c2b | |
**/ | |
add_filter( 'xa_change_estimated_delivery_date_format', 'ph_change_estimated_delivery_date_format' ); | |
if( ! function_exists('ph_change_estimated_delivery_date_format') ) { | |
function ph_change_estimated_delivery_date_format( $date ) { | |
global $wp_version; | |
//Give the desired formate here. | |
$format = "l F d Y"; | |
if ( version_compare( $wp_version, '5.3', '>=' ) ) { | |
if (date_default_timezone_get()) { | |
$zone = new DateTimeZone(date_default_timezone_get()); | |
}else{ | |
$zone = new DateTimeZone('UTC'); | |
} | |
$formatted_date = wp_date( $format, strtotime($date), $zone ); | |
}else{ | |
$formatted_date = date_i18n( $format, strtotime($date) ); | |
} | |
return $formatted_date; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment