Date Formats

Please note this page refers to using date/times in the API and not the format of dates as printed on the front-end of the site.

All date parameters expect dates in the format Y-m-d (e.g. 2013-12-24). If a time is also to be specified this can be provded in 12 or 24 hour format, but when using 12-hour time pm and am must be specified in English (not a translation of them). E.g. 2013-12-24 13:20 or 2013-12-24 1:20pm. Strictly speaking date strings are interpretted by php’s DateTime(), so this format is flexible however the Y-m-d H:i format is recommended.

You can also use ‘relative date formats’.

Relative Date Formats

Usually you don’t want to query events by a static date, but instead want to query events relative to some point in time. For example you may want to retrieve events that start tomorrow, occur next month, or have finished in the last week.

Event Organiser allows you to give certain date-related query arguments in ‘relative date format’. For example:

  • tomorrow,
  • now,
  • +1 week,
  • third Thursday of this month

etc.

So what relative date formats are allowed?

The interpretation of relative strings is done via native php functions, so a full list of available formats can be found here.

Please note which relative statements are available to you depends on the php version you are running WordPress on. For example ‘first day of this month‘ is only supported by PHP 5.3+

If you wish to test how a relative dates will be interepreted you can use the relative date tester.

Examples

Examples using the API

Events running from today until two months time

  <?php $events = eo_get_events(array( 
                     'event_end_after'=>'now', 
                     'event_start_before'=>'+2 month'
                   )); ?> 

Events running this week (Monday to Sunday)

    <?php eo_get_events(array( 
          'event_end_after'=>'last Monday', 
          'event_start_before'=>'this Sunday', 
          'showpastevents'=>1 
       )); ?> 

Examples using the event list shortcode

Using the shortcode to list past events

 [eo_events event_end_before="today" showpastevents=true ]

Using the shortcode to list events running this month

  [eo_events event_start_before="last day of this month" event_end_after="first day of this month" showpastevents=true]

Using the shortcode to list events starting this month

  [eo_events event_start_before="last day of this month" event_start_after="first day of this month" showpastevents=true]