This extension creates a shortcode that can be used to embed an event’s start or end date and/or time anywhere throughout your site.
The following is an example of what would be used in the WordPress post editor:
[tribe_formatted_event_date id=1234 format="F j, Y, \\a\\t g:ia T" timezone="America/New_York"]
This example would do the following:
- Fetch the event start date and time information for the event with ID #1234
- Define the date format as: Month Name, Day Number, Four-Digit Year
- Display the word “at” (each “raw” letter within the format shortcode argument must be double-escaped)
- Define the time format as: 12-hour with AM/PM and timezone abbreviation
- Convert the event’s start time to be displayed in Eastern Time
For an event that starts August 2, 2017 at 11 AM Central Time, the final result of the above example would print the following information in the page or post where the shortcode is used:
August 2, 2017, at 12:00pm EDT
This is a handy shortcut for being able to reference an event’s start date and time dynamically in a page or post without having to update the content if the event post information is edited.
This shortcode can also be used to display the event end date and/or time, like this:
[tribe_formatted_event_date id=1234 start_end="end" format="g:ia T"]
For an event that ends August 2, 2017 at 3pm Central Time, the shortcode’s output for this example would be:
Start and End Shortcodes Used Together
Here’s an example that uses the shortcode twice for a single event (same IDs):
[tribe_formatted_event_date id=1234 format="F j, Y \\f\\r\\o\\m g:ia"] - [tribe_formatted_event_date id=1234 format="g:ia T" start_end="end"]
August 2, 2017 from 11:00am - 3:00pm CDT
Notice the double-escaped “from” and the hyphen that’s outside the shortcodes.
Please reference PHP’s date() formats for all the formatting options available in the shortcode’s format argument.