How would one display the Month, Day, and Day-Of-Week as separate items?

Home Forums Calendar Products Events Calendar PRO How would one display the Month, Day, and Day-Of-Week as separate items?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1373806
    marcuszeal
    Participant

    In my current build, I’m trying to echo out 3 events and in those 3 events show the date to the left, but styled accordingly.

    I’ve been able to echo out the events using tribe_get_events, but I can’t seem to grab the date of the event or the day of the week of the event.

    I was able to get the Month of the event from a previous post on the forums.

    <?php echo date_i18n( F, strtotime( tribe_get_month_view_date($post) ) ); ?>, but it shows the entire month instead of the abbreviated version.

    Are there functions that I can grab onto for these? I didn’t see any, but I feel like there must be.

    I’m attaching a quick mockup of what I’m trying to do.

    #1373927
    marcuszeal
    Participant

    I’ve figured it out! The support post that suggested the code above was simply wrong for this example. The solution is to use the new tribe_get_start_date function and the date_format multiple times to echo out what you need for each. Makes sense now that I’ve said it all outloud. lol

    Here’s My Code (For the next guy!):

    
    <section class="upcoming-events">   
    <?php 
    // Ensure the global $post variable is in scope
    global $post;
     
    // Retrieve the next 3 upcoming events
    $events = tribe_get_events( array(
        'posts_per_page' => 3,
    ) );
    
    foreach ( $events as $post ) {
        setup_postdata( $post );
    	?>
    	<div class="event-list">
    		<div class="large-date">
    			<span class="month"><?php echo tribe_get_start_date ( $post, $display_time = false, $date_format = M );  ?></span>
    			<span class="day">  <?php echo tribe_get_start_date ( $post, $display_time = false, $date_format = d );  ?></span>
    			<span class="week"> <?php echo tribe_get_start_date ( $post, $display_time = false, $date_format = D );  ?></span> 
    		</div>
    		
    		<div class="event-info">	
    			<a href="<?php tribe_event_link(); ?>" class="event-link"></a>
    			<h5><?php echo "$post->post_title"; ?></h5>
    			<p class="event-date"><?php echo tribe_get_start_date( $post );  ?></p>
    		</div>
    	</div> 
    <?php 
    	}
    ?>
    
    </section>
    
    

    The important bits tho:
    <?php echo tribe_get_start_date ( $post, $display_time = false, $date_format = M ); ?>
    That “M” is displaying the truncated Month (Jan – Dec). All the formats can be found here: http://php.net/manual/en/function.date.php

    #1374000
    Geoff B.
    Member

    Good afternoon Marcus and welcome to the Events Calendar Support forum!

    Thank you for reaching out to us.
    Kudos for figuring things out and most importantly for sharing (for everyone’s benefit).

    You are welcome back in our support forums any time 🙂

    For now, I am going to close this thread.

    Have a great week!

    Geoff B.

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How would one display the Month, Day, and Day-Of-Week as separate items?’ is closed to new replies.