How to display datetime on event-meta-event-single.php

WordPress Event Management, Calendars & Registration Forums Frontend Submissions How to display datetime on event-meta-event-single.php

This topic contains 3 replies, has 2 voices, and was last updated by  Stephen Harris 7 years ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26887

    Hi,

    I saw on the codex this:

    eo_format_datetime( $datetime, $format = 'd-m-Y' )
    

    How would I set this up in this unordered list to check the condition if it exists, then display the range of date when the event happens and when it ends?

    <ul class="eo-event-meta">
          // I don't need eo_recurs bc it's only a one day event 
          <?php if ( //code here to check if datetime exists// ) { ?>
               
  • <?php echo eo_format_datetime( $datetime, $format = 'd-m-Y' );?>:
  • <?php } ?>
    Webmaster CCC
    #26895

    How would I set this up in this unordered list to check the condition if it exists

    An event always has a start and end date, so there’s no need to check if these exist.

    To format the range of the start and end datetime I would recommend using eo_format_event_occurrence(). See http://codex.wp-event-organiser.com/function-eo_format_event_occurrence.html

    You could use it as follows in your single-event.php or event-meta-single-event.php:

    $occurrences = eo_get_the_occurrences_of(); //This should be array of one element for you 
    $occurrence_id = (int) key($array); //we're just grabbing an occurrence ID
    echo eo_format_event_occurrence( get_the_ID(), $occurrence_id );
    

    This will, by default, use your site’ss date/time format, but display the start and end date time as range.

    Stephen Harris
    #26897

    Thank you I tried this and it works as well:

    <?php if ( ! eo_recurs() ) { ?>
              <!-- Single event -->
               
  • <?php _e('Start:', 'eventorganiser') ;?> <?php eo_the_start('F jS Y g:ia'); ?>
  • <?php _e('End:', 'eventorganiser') ;?> <?php eo_the_end('F jS Y g:ia'); ?>
  • <?php } ?>

    The issue is, when the user clicks on all day. The Start and End time displays as:

    Start: May 1st 2017 12:00am

    End: May 1st 2017 11:59pm

    I would like to have the condition for it to say : All Day

    So I’m thinking something like this (pseudocode here):

    If ( user checks on all day box in the fes form) {
             
  • Time: All Day
  • Else { <!-- Single event -->
  • <?php _e('Start:', 'eventorganiser') ;?> <?php eo_the_start('F jS Y g:ia'); ?>
  • <?php _e('End:', 'eventorganiser') ;?> <?php eo_the_end('F jS Y g:ia'); ?>
  • <?php } ?>
    }

    I can’t find a query on the codex for the all day check box.

    Webmaster CCC
    #26902

    You can replace 'F jS Y g:ia' with:

    eo_get_event_datetime_format( get_the_ID(), 'F jS Y', 'g:ia' )
    
    Stephen Harris
Viewing 4 posts - 1 through 4 (of 4 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.