Hide DATE record if no entry made.

2 posts by 1 authors in: Forums > CMS Builder
Last Post: September 22, 2017   (RSS)

By Zicky - September 22, 2017

I have a date field that I need to display only if an entry has been made. I'm trying to use an IF Statement to only show the event's date if an entry is made AND the date is not assigned some default date like 0000-00-00 00:00:00

My date field is set up with the "Default Value: None/Blank" but I'm still getting a date and therefore the field appears on my web page, but and reads "Nov 30, -0001 12:00 am"

Anyone have any suggestions on how to NOT display a date record on the page if not date entry is made? Below is the code I'm using on the web page.

<?php if ($eventRecord['date'] && !$eventRecord['date']='0000-00-00 00:00:00'): ?>
        <?php echo date("M d", strtotime($eventRecord['date'])) ?>, <?php echo date("Y", strtotime($eventRecord['date'])) ?> <?php echo date("g:i a", strtotime($eventRecord['date'])) ?>
<?php endif; ?>

Thanks, Zicky