Page 1 of 1

Changing Date format produces 12/31/1969 for null values

PostPosted: Wed Jul 21, 2010 12:05 pm
by transcan
Hello.

When using this delegate to change the date format from YYYY-MM-DD to MM-DD-YYYY, it works for dates inputted and retrieved, however for certain fields that remains blank until a date is entered in the near future, 12/31/1969 is displayed instead of blank. How can this be fixed to show a blank and still show the correct date format of MM-DD-YYYY?

Code: Select all
    function delivery_date__display(&$record){
        return date('m/d/Y', strtotime($record->strval('delivery_date')));


Thanks in advance.

Re: Changing Date format produces 12/31/1969 for null values

PostPosted: Wed Jul 21, 2010 4:48 pm
by shannah
Evidently strtotime($record->strval('delivery_date')) is returning 0.
Try just changing this to:
Code: Select all
function delivery_date_display(&$record){
    return $record->strval('delivery_date');
}

to see what it gives you. Likely it is giving you an empty string which means either you have a typo, or the record has no date set.

-Steve

Re: Changing Date format produces 12/31/1969 for null values

PostPosted: Thu Jul 22, 2010 7:35 am
by transcan
Yes, the function works. Thanks.