WooCommerce: Show Published Date @ Single Product

Hello WooCommerce Customizers! Today we take a look at the WooCommerce Single Product Page and specifically at how to display the product/post published date. It might be useful to users in case you need to show how “new” a product is, or if you have specific needs. Enjoy ๐Ÿ™‚

WooCommerce: Show Product Published Date
WooCommerce: Show Product Published Date

PHP Snippet: Show Product Published Date @ WooCommerce Single Product Page

/*
 * @snippet       WooCommerce: Show Product Published Date
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 5
 * @community     https://businessbloomer.com/club/
 */

add_action( 
 'woocommerce_single_product_summary', 'bloomer_echo_product_date', 25 );

function bloomer_echo_product_date() {
   if ( is_product() ) {
      echo the_date( '', '<span class="date_published">Published on: ', '</span>', false );
   }
}

// Change the date format: https://codex.wordpress.org/Function_Reference/the_date

Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce Visual Hook Guide: Single Product Page
    Here’s a visual hook guide for the WooCommerce Single Product Page. This is part of my “Visual Hook Guide Series“, through which you can find WooCommerce hooks quickly and easily by seeing their actual locations (and you can copy/paste). If you like this guide and it’s helpful to you, let me know in the comments! […]
  • WooCommerce: Disable Variable Product Price Range $$$-$$$
    You may want to disable the WooCommerce variable product price range which usually looks like $100-$999 when variations have different prices (min $100 and max $999 in this case). With this snippet you will be able to hide the highest price, and add a “From: ” prefix in front of the minimum price. At the […]
  • WooCommerce: Hide Price & Add to Cart for Logged Out Users
    You may want to force users to login in order to see prices and add products to cart. That means you must hide add to cart buttons and prices on the Shop and Single Product pages when a user is logged out. All you need is pasting the following code in your functions.php (please note: […]
  • WooCommerce: Add Custom Field to Product Variations
    Adding and displaying custom fields on WooCommerce products is quite simple. For example, you can add a “RRP/MSRP” field to a product, or maybe use ACF and display its value on the single product page. Easy, yes. Unfortunately, the above only applies to “simple” products without variations (or the parent product if it’s a variable […]
  • WooCommerce: Show Number Of Products Sold @ Product Page
    WooCommerce database already stores the number of products sold for you. Therefore, you may want to show such number on the product page, close to the Add To Cart button. As we’ve seen in my book Ecommerce and Beyond, showing the number of sales for each product can increase your sales conversion rate. All you […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

24 thoughts on “WooCommerce: Show Published Date @ Single Product

  1. Thanks for your great article, I’d like to ask, is there any way to get the ” product’s last modified time ” by product ID?

  2. This is great. Is it possible to move this below the button?

    1. Cool! Try increasing the priority (which is 25 at the moment)

  3. Hello Rudolfo. Thanks for that awesome snippet of code. I was curious if it is possible to show on shop everywhere, you know what I mean, shop-page, category pages. Would need to show Date Added in those Product Columns hmm. Thanks very much, you are the man!

    1. Hi Michal, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. It worked perfectly even today, thanks.

    1. Awesome!

  5. Hi Rodolfo,

    It’s not the same, but related. Do you know how to export the published date?
    So far I’ve been able to add other elements to the exporting CSV that comes bundled in WC, like the slug, but with the date, nothing so far.
    Your help is appreciated, thanks!

    1. Hey Santiago, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  6. Hello, I sell one of a kind products! I would like to show the month/year it was sold when a visitor sees the product page …any code to help me with this please??

    1. Hello James, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  7. how to show woocommerce product publish time on shop page. I am using vantage and Di blog themes.

    1. Hey there, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  8. Hi Rodolfo

    cool snippet. Is it possible to show it on a product attribute?

    thx, bye

    1. Mabi, thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. Thanks a lot for your understanding! ~R

  9. Is there a way to change the functionality so that is will show the last updated date instead?
    Thank you.

    1. Sorry Marian, I thought I replied to this comment already. Of course there is – but I’m afraid I cannot provide support here via the blog comments ๐Ÿ™‚ Thanks for your understanding. R

  10. how to display date in shop page also. this one displays date on product page but what about product list page or shop page.

    1. Hey Sachin thanks for your comment! You could try using another hook (reference: https://businessbloomer.com/woocommerce-visual-hook-guide-archiveshopcat-page/) in order to make it show on the shop page. Hope this helps ๐Ÿ™‚

  11. How would I use this to get the product publish date when trying to calculate selling time to be stored to order items meta data? I’m using wc_add_order_item_meta function and hook to store the information of for the order items but don’t know how to get the date easily. Any ideas?

    1. Hey Juhani, thanks for your comment! Your request is a little off topic… but here’s what I’d do: when you open any order within WooCommerce admin, you will see date and time. Somewhere in the WooCommerce code, there is a function that is saving that timestamp already – all you need to do is to “get” it via PHP and echo the value on emails or pages. Hope this helps!

    1. Thank you Zoran ๐Ÿ™‚

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *