How to Change the Date Format for the Delected Date in the Reservation Table

If you want to modify the date format for the select timeslot label in the Reserve button of the Reservation table, then you can use the code snippet below to do it.

date format reservation table
  1. Open your child theme’s functions.php file or use a Code Snippets plugin.
  1. Copy and paste the following code snippet:
/**
 *  Modify the format of the selected date in the Reserve button in the Reservation Table.
 *
 * @param array $dates Dates.
 */
function iconic_wds_modify_date_format_reservation_table( $dates, $format ) {
	if ( ! wp_doing_ajax() ) {
		return $dates;
	}

	if ( 'array' !== $format ) {
		return $dates;
	}

	foreach ( $dates as &$date ) {
    // TODO - Please replace with your preferred date format.
		$date['formatted'] = date_i18n( 'D, j M', $date['timestamp'] );
	}

	return $dates;
}
add_action( 'iconic_wds_available_dates', 'iconic_wds_modify_date_format_reservation_table', 10, 2 );
 
  1. Update the timeslot in line 12 with your desired date format. You can refer to the list of all date formats available at api.jqueryui.com/formatDate. For example, if you want to display the date as “Tuesday, 17 Oct”, you can use the format ‘D, j M’.
  2. Save the file or update the Code Snippets plugin.

Note: Make sure to test the code changes on a development or staging site before applying them to a live site.

WooCommerce Delivery Slots

Choose a delivery date and time for each order. Add a limit to the number of allowed reservations, restrict time slots to specific delivery methods, and so much more.

Was this helpful?

Please let us know if this article was useful. It is the best way to ensure our documentation is as helpful as possible.