Product table date sorting and date / time format
If you want to display date and time formats in WooCommerce Product Table, then there are several options for controlling how dates and times are treated. For example, you can tell WooCommerce Product Table which columns are dates so that it will sort by date rather than alphabetically.
The options on this page do not appear on the plugin settings page, and should be set directly in the shortcode for each product table that contains dates.
Extra date columns
date_columns option lets you designate specific columns in your table as dates, so that the column can be sorted by date correctly. This can be useful for custom fields or taxonomies which contain dates, as otherwise they will be sorted alphabetically instead of by date.
[product_table columns="name,cf:custom_date,add-to-cart" date_columns="cf:custom_date" date_format="d-m-y"]
date_format option lets you control how the
date column is formatted in your product table. It is also used for any other column you have specified as a date (see above).
If you don’t set this option, the default format in your WordPress settings will be used (see ‘Date Format’ under Settings > General in WordPress).
You can set the date format to any valid date/time format string. For example:
F j, Y will format the dates in this format: “August 24, 2016”. See the WordPress Codex for more information.
[product_table columns="name,date,price" date_format="F j, Y"]
The date format isn’t working for custom fields
If the date format is wrong despite using the
date_format options in your shortcode, then your custom field plugin is probably overriding the date format. To fix it, go to the settings for your custom field (e.g. in Advanced Custom Fields, or whichever custom field plugin you are using) and look for the date format option. Try setting the date format here so that it matches the setting in WooCommerce Product Table.
To get this working, you may need to remove the
date_format option from your Product Table shortcode. This will prevent it from conflicting with the date format in the custom field plugin.