I’m trying to compare a date in an if statement. If “all day” is checked, the m/d/y of each date is the same, but the UTC timecode of the date is different. How to I compare just the m/d/y part to see if they are equal or not? Here is my code so far:
<div>
{if "{calendar:event_first_date format='%m%d%Y'}" != "{calendar:event_last_date format='%m%d%Y'}"}
<dt>Dates:</dt>
<dd>{calendar:event_first_date format="%F %j, %Y"} - {calendar:event_last_date format="%F %j, %Y"}</dd>
{if:else}
<dt>Date:</dt>
<dd>{calendar:event_first_date format="%F %j, %Y"}</dd>
{/if}
</div>
This code isn’t working as only the else statement is being entered. Thanks for any help you can offer!
I would think that would work unless it doesn’t take the format into account when running the comparison. Have you tried outputting {calendar:event_first_date format='%m%d%Y'}
{calendar:event_last_date format='%m%d%Y'}
outside of the conditional to make sure what is being outputted is equal or not.
Hmm, so strange. Thanks so much for your replies. Still no idea why it’s not working on my end. I’ve switched over to a different conditional that seems to be doing the trick. I think for some reason it’s my calendar add-on not doing what it’s supposed to be doing, or simply me being a complete noob with Expression Engine, so I don’t really know the ins and out of it yet.
Anyway, I’ve learned that the Add-on we’re using is the EE Calendar add-on by solspace.
https://docs.solspace.com/expressionengine/calendar/v3/templating/events.html#parameters
I’ve begun using the {if calendar:event_recurs} tag, and that seems to be getting me into the conditional just fine.
Maybe this is for another thread, but now I’m having issues getting all of my recurring dates to show. Just can’t seem to figure it out, and don’t really know if this is the right forum to ask that, or if I need to go to the calendar support page instead.
ok. I was going this with the native date fieldtype in EE. If you’re using Solspace Calendar, then you should definitely reach out to them. They’re good people and should be able to help you out.
You can also jump over to the EE Slack channel. There are a lot more people watching that who might be able to help you out: https://expressionengine.com/blog/join-us-in-slack#join-us-on-slack
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.