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
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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 this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

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.

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? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. 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 BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published.