Changing Date format produces 12/31/1969 for null values
Archived from the Xataface Users forum.
transcan — Wed Jul 21, 2010 12:05 pm
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.
shannah — Wed Jul 21, 2010 4:48 pm
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
transcan — Thu Jul 22, 2010 7:35 am
Yes, the function works. Thanks.