Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.