Home › Forums › Calendar Products › Events Calendar PRO › Customize time format in metadata?
- This topic has 16 replies, 5 voices, and was last updated 9 years, 1 month ago by
William Lee.
-
AuthorPosts
-
January 30, 2017 at 12:03 pm #1226364
William Lee
ParticipantI’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.
January 30, 2017 at 12:06 pm #1226367George
ParticipantHi 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.phpWe 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,
GeorgeFebruary 1, 2017 at 6:54 am #1227468William Lee
ParticipantHm. Okay. Is there a way to display just the date then and not the time?
February 1, 2017 at 4:23 pm #1227881George
ParticipantHey 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,
GeorgeFebruary 2, 2017 at 11:24 am #1228425Mathew
ParticipantWilliam,
Head over to the Extensions Library. I think you might find what you are looking for.
Here’s the direct link.
Hope this helps.
February 2, 2017 at 11:54 am #1228442William 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.
February 2, 2017 at 12:07 pm #1228453Mathew
ParticipantWilliam,
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.
February 2, 2017 at 12:19 pm #1228462William 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?
February 2, 2017 at 12:28 pm #1228476Mathew
ParticipantWilliam,
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.
February 2, 2017 at 12:31 pm #1228478William Lee
Participant@Mathew: Same result
February 2, 2017 at 12:52 pm #1228496Mathew
ParticipantWilliam,
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.
February 2, 2017 at 1:07 pm #1228504William Lee
ParticipantI 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?
February 2, 2017 at 8:10 pm #1228687George
ParticipantHi 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,
GeorgeFebruary 3, 2017 at 5:16 am #1228845William Lee
ParticipantNope. Unfortunately I get the same result. Strange!
February 6, 2017 at 6:24 am #1229933George
ParticipantHey 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 -
AuthorPosts
- The topic ‘Customize time format in metadata?’ is closed to new replies.
