Support » Plugin: Event post » Display begin date in template

  • Resolved akalwp


    me again ^^
    Currently I’m using <?php echo get_post_meta( get_the_ID(), ‘event_begin’, true ) ; ?> in page template, which display date like 2018-10-01 00:00:00
    How could I echo the event date (event_begin) in human way like 01 oct 2018 ?

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Bastien Ho



    The easy way, which will crash if you deactivate the plugin:

    <?php the_date_start();?>

    The coder way:

    <?php echo date('m/d/Y H:i' , strtotime(get_post_meta( get_the_ID(), ‘event_begin’, true ))  ); ?>

    (replace with the appropriate time format)

    Or use the built-in WordPress function date_i18n()

    Hope it helps

    • This reply was modified 2 years, 11 months ago by Bastien Ho.
    Thread Starter akalwp


    <?php the_date_start();?>
    Perfect !
    Thx 😉

    is it possible to have nothing written instead of 01/01/1970?
    i’m using this way:
    <?php echo date(‘m/d/Y H:i’ , strtotime(get_post_meta( get_the_ID(), ‘event_begin’, true )) ); ?>

    i have found how to 🙂

    $key_date_begin_value = get_post_meta( get_the_ID(), ‘event_begin’, true );
    $key_date_end_value = get_post_meta( get_the_ID(), ‘event_end’, true );

    // Check if the custom field has a value.
    if ( ! empty( $key_date_begin_value )||! empty( $key_date_end_value ) ) {
    $output .= ‘<span class=”post-date”>’ .$key_date_begin_value.’ ‘.$key_date_end_value;
    $output .= ‘<span class=”post-date”>’. get_the_date() .'</span>’;

    but to add the format I continue to search…
    if someone knows the solution, I’m interested


Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Display begin date in template’ is closed to new replies.