This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

📣 Join the live AMA session with Adam Silverstein on open source and WordPress core! Register Now →

How to Add Custom Date Format in WooCommerce

Updated on December 26, 2022

2 Min Read
woocommerce custom date format

The problem with date formats is that everyone has their own preference.

Admins and inventory managers often have different requirements for date formats. This often happens in WooCommerce stores, where stakeholders have different requirements to customize the date format.

In this short tutorial, I will show how to customize the WooCommerce date format without much effort. Note that the code for these functions should be added to the functions.php file located in the theme folder.

Default Date Format in WooCommerce

Fortunately, changing the default date format in WooCommerce simply uses a filter and a function.

To change the date and time format in WooCommerce, go to the “Settings” menu in the WooCommerce dashboard and click on the “General” tab. Scroll down to the “Date Format” and “Time Format” settings and choose the desired format from the drop-down menu.

From launching to customizing your WooCommerce stores, Cloudways is at your service.

Whether you’re a beginner or an expert, Cloudways Platform is based on UI, where you can create and customize your online store in a few seconds.

Add Custom Date Format in WooCommerce

Customizing the date format in WooCommerce is a simple process that can help to improve the user experience for customers and better align the store with your branding and style.

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 the format to D/M/Y, just modify the last line of the function to:

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

Alternate Method for Custom Date Format

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;
}

Summary

By customizing the date format in WooCommerce, you can easily control how dates and times are displayed throughout your online store. It is important to carefully consider the date format you choose, as it can impact how easily customers understand and interpret dates and times displayed on your WooCommerce store.

Share your opinion in the comment section. COMMENT NOW

Share This Article

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 [email protected]

×

Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!

×

Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour

CYBER WEEK SAVINGS

  • 0

    Days

  • 0

    Hours

  • 0

    Mints

  • 0

    Sec

GET OFFER

For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now