Customize time format in metadata?

Home Forums Calendar Products Events Calendar PRO Customize time format in metadata?

Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #1226364
    William Lee
    Participant

    I’m displaying events using Essential Grid so that I can more thoroughly customize how the displays look, but I’m running into an issue. When I pull data from “_EventStartDate” the time is formatted as YYYY-MM-DD HH:MM:SS. Is there anyway to output the time portion of that data as HH:MM in 12-hour time with am or pm added?

    I checked with the Essential Grid folks, but they suggested I ask you guys.

    #1226367
    George
    Participant

    Hi William,

    You can use the function tribe_get_start_date() to get the start date and time of an event in any date format you’d like.

    Head to this file in your copy of The Events Calendar to read the function and see how to use it, and how to specify a time format:

    the-events-calendar/common/src/functions/template-tags/date.php

    We cannot help with custom coding or similar questions but I do hope this helps you get started on displaying the event start date in a custom date/time format.

    Cheers,
    George

    #1227468
    William Lee
    Participant

    Hm. Okay. Is there a way to display just the date then and not the time?

    #1227881
    George
    Participant

    Hey William,

    Sure thing. Head to this file in your copy of The Events Calendar to read the function and see how to use it, and how to specify a time format:

    the-events-calendar/common/src/functions/template-tags/date.php

    ↑ In doing so, you’ll note that the second parameter of the function is a “True” or “False” option. If you set it to “False”, no time will be displayed — just the date! 😀

    Cheers,
    George

    #1228425
    Mathew
    Participant

    William,

    Head over to the Extensions Library. I think you might find what you are looking for.

    Here’s the direct link.

    Hope this helps.

    #1228442
    William Lee
    Participant

    @George: That didn’t do anything. I changed it to false, but the time still displays.

    @Mathew: Unfortunately that doesn’t help. (1) It seems that the shortcode is only for individual events (unless I’m misunderstanding it). (2) The Grid skins don’t use shortcodes but metadata keys.

    Thanks anyway. I feel like we’re so close to getting the right answer but just barely missing something.

    #1228453
    Mathew
    Participant

    William,

    Yes, Essential Grid does use metadata keys, but you can embed the key within the shortcode.

    Here’s a link to a recent support post on this very topic.

    Hope this gets you closer to a solution.

    #1228462
    William Lee
    Participant

    @Mathew: Almost there, I think! I’m getting an error that the post does not exist. I may not be using the right data. I’m using:

    [tribe_formatted_event_date id=”%post_id%” timezone=”New York” format=”F jS, Y @ g:i a” ]

    Am I missing something?

    #1228476
    Mathew
    Participant

    William,

    Try This:

    [tribe_formatted_event_date id="%post_id%" timezone="America/New_York" format="F jS, Y @ g:i a" ]
    

    Also, I think curly quotes are causing issue. Delete and re-type the quotes manually. Sometimes copy and paste in web pages causes formatting issues.

    #1228478
    William Lee
    Participant

    @Mathew: Same result

    #1228496
    Mathew
    Participant

    William,

    I cannot reproduce the error. I’m not sure where it’s coming from. Do you have debug turned on?

    Other than that, do you have the post type set to “Event” in Essential Grid? Under Settings -> Source -> Post Types.

    #1228504
    William Lee
    Participant

    I do have “Events” as the source type. I turned on debug, but didn’t get anything different or any helpful info. If I replace “%post_id%” with an actual post ID, it works beautifully. But of course only for one event. I can’t figure out what the problem is. It seems that it’s just not pulling in the post ID. Ugh. Once again…it feels like we’re ALMOST there!

    I appreciate all your help, Mathew. Any other ideas?

    #1228687
    George
    Participant

    Hi William,

    Do you have any progress if you just omit the ID parameter altogether? So that instead of something like this:

    [tribe_formatted_event_date id=”%post_id%” timezone=”New York” format=”F jS, Y @ g:i a” ]

    You just remove the id="" bit, so it looks more like this:

    [tribe_formatted_event_date timezone=”New York” format=”F jS, Y @ g:i a” ]

    This will get the shortcode to query for an event ID on its own, which may be helpful.


    Thanks so much for chiming in here, @Mathew! Great to see both of you chatting here.

    Cheers,
    George

    #1228845
    William Lee
    Participant

    Nope. Unfortunately I get the same result. Strange!

    #1229933
    George
    Participant

    Hey William,

    I’m sorry to hear that odd behavior is persisting.

    What you describe above is insightful:

    If I replace “%post_id%” with an actual post ID, it works beautifully.

    ↑ This confirms that the shortcode itself—and the retrieval of the specified event’s start date meta values—is working as expected. But there isn’t a global $post specified otherwise, which is why my recommendation in my reply above isn’t helping.

    I do not know the Essential Grid theme well, nor do I have a copy of it. Do you enter the shortcode for each post? If so, specifying the ID for each one may be the best solution here, even though it’s not ideal.

    If you don’t enter this shortcode post-by-post, and instead only enter it once in a template sort of thing, then I would recommend reaching out to the Essential Grid team for possible insights into how you can grab the global $post of the event item for use in shortcodes or some other way to programmatically do this.

    The shortcode itself, if there’s not an id="" attribute specified, uses the handy WordPress function get_the_ID(), so that may be helpful to share with the Essential Grid folks…

    …I’m sorry that I don’t have any other ideas here, but hope that working with the Essential Grid folks from here leads to a successful outcome.

    Please let me know if there are any other issues or questions I can try to help with.

    Sincerely,
    George

Viewing 15 posts - 1 through 15 (of 16 total)
  • The topic ‘Customize time format in metadata?’ is closed to new replies.