Skip to content

Instantly share code, notes, and snippets.

@PluginHive
Last active August 16, 2021 07:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PluginHive/7fb8f48c6b6f1d30d33ad50cb1a37c2b to your computer and use it in GitHub Desktop.
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/
/**
* 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