No date = 12/31/69 ?

7 posts by 4 authors in: Forums > CMS Builder
Last Post: October 29, 2010   (RSS)

By zip222 - October 27, 2010

One of my section editors has an optional date field, but if you leave it blank it stores the date of 12/31/69. Why does this happen, and is there a way around this?

Re: [zip222] No date = 12/31/69 ?

By Jason - October 27, 2010

Hi,

This happens when you pass a 0 value into the date() function. Is this value getting in from an html form? If so, please attach the .php page that you're working with and I can take a look at it.

Hope this helps.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [zip222] No date = 12/31/69 ?

By Jason - October 27, 2010

Hi,

Okay, if you could fill out a second level support request here:
https://www.interactivetools.com/support/email_support_form.php
I can take a closer look at this. In your request, please indicate which field in which section is experiencing the problem.

Thanks.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] No date = 12/31/69 ?

By zip222 - October 27, 2010

Submitted. Thanks.

Re: [Jason] No date = 12/31/69 ?

By Damon - October 27, 2010

For anyone else following this thread, here is the IF statement code to handle blank dates in templates:

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


It will only output the date if it has a value.
Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Damon] No date = 12/31/69 ?

I've attached a plugin that Dave created called:

removeExtraWhitespace


It automatically checks for fields that only contain blank spaces as well as blank dates.

It checks for the blank spaces (which can mess up "if" statements) when you're creating the record, so it won't check existing records before outputting their data, but it will help going forward.

The plugin requires 2.05

best,

Jerry Kornbluth
The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php