1. Home
  2. Documentation
  3. WooCommerce Product Table
  4. Product Table Shortcode Options
  5. Product table date sorting and date / time format

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

The 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.

Example:

 [product_table columns="name,cf:custom_date,add-to-cart" date_columns="cf:custom_date" date_format="d-m-y"]

Date format

The 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.

Example: [product_table columns="name,date,price" date_format="F j, Y"]

Was this article helpful?

Related Articles