0

I'm trying to find a way in Calendar for start times that are on the hour (e.g., 8:00pm) to output as "8pm" and for times that are not on the hour (e.g., 8:15pm) to output as "8:15pm". I'm not figuring out how to write the conditional to do that. Any ideas?

EDIT: Just to make this a little more clear, I want any times that are on the hour to just be the hour (8:00pm should render as 8pm) and any times that are not on the hour should have the hour and the minutes (8:25pm should render as 8:25pm).

2 Answers 2

0

You should have a look at the demo templates, as this problem was solved there. :)

You actually need to use a different time variable available to you:

{event_start_date format="%g"}
{if event_start_minute > 0}
   :{event_start_minute}{event_start_date format="%A"}
{/if}
1
  • Thanks, this worked! I was looking in the docs rather than the demos, but I'll check those out more.
    – edward
    Commented Feb 16, 2016 at 14:12
0

You should be able to handle this like any other conditional using the event_start_date variable.

So if you wanted something that wasn't a specific hour, but for ANY time, you could do something like:

{if "{event_start_date format='%i'}" == "00"}
    {event_start_date format='%g:%i%A'}
{if:else}
    {event_start_date format='%g:15%A'}
{/if}
1
  • Thanks for the suggestion! It looks like it should work, however the first line {if "{event_start_date format='%i'}" == "00"} isn't figuring it out when the time is 8:00pm. In other words, it's giving me the same format whether the time is 8:00 or 8:15.
    – edward
    Commented Feb 12, 2016 at 19:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.