Jump to content

DateObject and Nulls


Jonob

Recommended Posts

Hi all,

 

I have an array mapped to a value object. One of the items in the array is a PHP DateObject, and I need to format this field appropriately.

 

When looping through the array, I pass this field to a function as follows: (simplified for expendiency)

if (!is_null($date))
{
  return date_format($date, "Y-m-d");
}

This works great, except for the case when the DateObject contains a null value - in this case the above function seems to always return the current date.

 

I am guessing that this is because $date is not really null (i.e. it contains an object, even though the object is null), but I am not sure how to get around this.

 

Any help greatly appreciated.

 

Link to comment
https://forums.phpfreaks.com/topic/178836-dateobject-and-nulls/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.