Modern events calendar time key

Hey, I’m trying to show upcoming events from the modern events calendar on my start page and have one issue:

I want to show the start time of the even with the following code:

{{dc:post:meta key=“mec_start_hour” type=“time” format=“G:i”}}

But it just gives me the current time and not the start time that was set in the event.
I’m able to show the event date but it’s just not working out for the start time.
Could you help me out here? Am I using the wrong key?

Best regards,
Phil

Hello Phil,

Thank you for the inquiry.

According to this older thread, you’re retrieving the correct field.

MEC events and looper consumer

What happens when you remove the type and format parameters?

{{dc:post:meta key="mec_start_hour"}}

Please provide the login details in the secure note so we can further check the issue.

Best regards.

Thx for the quick reply:

I’ve already tried removing everything but the key - but then it doesn’t output anything…

Thank you for the info.

We managed to retrieve the correct start time using Twig, but we can’t convert it to a 24-hour format.

{% set hour = post.meta({"key":"mec_start_time_hour"}) %}
{% set minutes = post.meta({"key":"mec_start_time_minutes"}) %}
{% set minutes = minutes is not defined or minutes == 0 ? '00' : minutes %}
{% set time_string = hour ~ ':' ~ minutes %}
{% set start = time_string|date('H:i') %}

{{ start }} Uhr

Let us know if this works for you.

Hey thx - well I need the 24 hour format, since we don’t use am/pm in germany and people will be confused.
Any idea why it is not showing up correctly?

We managed to convert the start time to 24-hour format using the mec_start_time_ampm meta field. Please make sure to purge the cache before testing.

Awesome - it works!
Thx very much, Ismael :slight_smile:

Hi @PhilTone,

Glad that we are able to help you.

Thanks

1 Like