Categories: WooCommerce Tutorials, Tips and GuidesWordPress Tutorials, Tips and Guides

Customize WooCommerce Date Format

The problem with date formats is that everyone has their own requirements. In many cases, admin people and inventory management have different requirements for date formats. This often happens in WooCommerce based projects where different stakeholders have different requirements for date formats.

Fortunately, changing the default date format in WooCommerce is simply a matter of using a filter and a function. In this short tutorial, I will demonstrate how to change the WooCommerce date format. Note that the code for this functions should be added to the functions.php, located in the theme folder. 

The following code alters the WooCommerce date format to Y/M/D:

add_filter('woocommerce_admin_order_date_format', 'cw_custom_post_date_column_time');
function cw_custom_post_date_column_time($h_time, $post)
   return get_the_time(__('Y/m/d G:i', 'woocommerce'), $post);

If you want to change format to D/M/Y, just alter the last line of the function to:

 return get_the_time(__('d/m/Y G:i', 'woocommerce'), $post);

Alternate Method

The following code option presents an alternate solution for the problem:

add_filter( 'post_date_column_time' ,'woo_custom_post_date_column_time_withDate' );
function woo_custom_post_date_column_time_withDate( $post ) {  
$t_time = get_the_time( __( 'd/m/Y g:i:s A', 'woocommerce' ), $post );
return $t_time;

add_filter( 'post_date_column_time' , 'woo_custom_post_date_column_time' );
function woo_custom_post_date_column_time( $post ) {
$h_time = get_the_time( __( 'd/m/Y', 'woocommerce' ), $post );
return $h_time;

Wrapping Up

Changing the date format in WooCommerce is a simple task that is often an essential requirement of many projects. If you need help, just drop a comment below.

Owais Alam :is the WordPress Community Manager at Cloudways - A Managed WooCommerce Hosting Platform and a seasoned PHP developer. He loves to develop all sorts of websites on WordPress and is in love with WooCommerce in particular. You can email him at owais.alam@cloudways.com