DATE RANGES - hiding range separator (dash)

5 posts by 2 authors in: Forums > CMS Builder
Last Post: April 12, 2018   (RSS)

By csdesign - April 12, 2018

Hello! 

I hate to even ask this questions because it seems SO obvious. Help is very much appreciated! 

I'm setting up an events calendar and I have a start date and and end date.  If no end date is given then just the start date shows. That's all done.

However, if there is NO end date (it's a one day event) how do I hide the dash? I've tried a few things but took them out to hide how clueless I am on this ;) 

Displays as: 

Sep 4 - Sep 7 , 2018   (if end date is entered)
Jan 1 - , 2018  (if end date is not entered)

<?php echo date("M j", strtotime($record['start_date'])) ?> - 

<?php if ($record['end_date'] && $record['end_date']!=0): ?>
<?php echo date("M j", strtotime($record['end_date'])) ?>
<?php endif ?>

<?php echo date(",  Y", strtotime($record['start_date'])) ?>

Thanks so much! Tina

By Toledoh - April 12, 2018

Could you just move the dash into the "If"

<?php echo date("M j", strtotime($record['start_date'])) ?>

<?php if ($record['end_date'] && $record['end_date']!=0): ?>
- <?php echo date("M j", strtotime($record['end_date'])) ?>
<?php endif ?>

<?php echo date(",  Y", strtotime($record['start_date'])) ?>

Cheers,

Tim (toledoh.com.au)

By csdesign - April 12, 2018

Wow, so obvious now... that worked perfectly... this does not bode well for the rest of my day ;)  thanks so much Tim! 

By csdesign - April 12, 2018

ha.. geez. Obviously I've either had too much or not enough caffeine