We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Compare months of two dates

How Do I?

bap1130's avatar
bap1130
3 posts
8 years ago
bap1130's avatar bap1130

I’m relatively new to EE and I’m working on an EE site where I have a calendar of events, some of which span 3 or 4 days. For example, an event runs July 13-16. I’m able to compare the start date of the event and end date of the event (both of which are stored as EE variables for each entry), and by comparison, I can decide if I need to print just “July 13” or “July 13-16”.

However, the issue I am having is when an event spans over two months. For instance “May 31 - June 2”. By using the same method, I end up with “May 31 - 2”. I’ve searched high and low trying to figure out a way to compare the months of two dates, but have not been successful.

{startDate format="%F %j"} {if endDate != startDate} {if {startDate format="%n"} != {endDate format="%n"}} <!–This is the comparison that breaks –> - {endDate format="%F %j"} {if:else} - {endDate format="%j"} {/if} {/if}

Thanks in advance for any suggestions or input!!!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.