How to change the date format?

Home Forums Calendar Products Events Calendar PRO How to change the date format?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1251354
    Laith
    Participant

    Dear Support,

    although you have a thread for this question but I did not find there the answer.

    I have WP German Installation. Thus the default settings for time should be fine.
    With The Event Calendar I got the following format: Start-Month Start-day @start-time – End-Month End-day@End-time
    Example: Dezember 11@09:00 am – Dezember 13@5:00 pm
    You can see it in this example here: https://successful-coding.de/event/java-clean-code
    But what I really need is : start-day start-month to end-day end-month from start-time to end-time
    This menas: 11-Dezember to 13-Dezember from 09:00 to 17:00.

    How can I achieve this please? Is this possible?

    I am really looking forward your answer

    Best regards

    Laith

    #1251956
    Barry
    Member

    Hi Laith,

    Great question!

    We provide various settings to control date formatting in the Events → Settings → Display admin screen however in this case you would probably need some custom code to bring about the formatting you desire:

    function custom_event_schedule_format( $html, $event_id ) {
    	$start_date = tribe_get_start_date( $event_id, false, 'j-F' );
    	$start_time = tribe_get_start_date( $event_id, false, 'H:i' );
    	$end_date = tribe_get_end_date( $event_id, false, 'j-F' );
    	$end_time = tribe_get_end_date( $event_id, false, 'H:i' );
    
    	$description = $start_date;
    
    	if ( $end_date !== $start_date ) {
    		$description .= " to $end_date";
    	}
    
    	if ( $start_time !== $end_time ) {
    		$description .= " from $start_time to $end_time";
    	}
    
    	if ( $start_time === $end_time ) {
    		$description .= " at $start_time";
    	}
    
    	return $description;
    }
    
    add_filter( 'tribe_events_event_schedule_details_inner', 'custom_event_schedule_format', 10, 2 );

    The above (which is just a starting point you can further adjust to meet your needs) could be added either to a custom plugin or even to your theme’s functions.php file.

    Does that help at all?

    #1262660
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How to change the date format?’ is closed to new replies.