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

A place for users and developers of the Xataface to discuss and receive support.

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

Postby 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.
transcan
 
Posts: 13
Joined: Wed Jul 21, 2010 11:57 am

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

Postby 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
shannah
 
Posts: 4457
Joined: Wed Dec 31, 1969 5:00 pm

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

Postby transcan » Thu Jul 22, 2010 7:35 am

Yes, the function works. Thanks.
transcan
 
Posts: 13
Joined: Wed Jul 21, 2010 11:57 am


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 3 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved