DateObject and Nulls


Posted on 16th Feb 2014 07:03 pm by admin

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)
Code: [Select]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.

70 Like 7 Dislike
Previous php-forum Next php-forum
Other php-forum

Having a problem get the selected item from a drop down menu
I have been looking at this for days now.

I have a drop down menu that get it's values from a

CHECK A STRING FOR ' " ' (DOUBLE QUOTES)
I am checking for delimiter (.!?) and if there is a " after a sentence then it should neglect a

apart from cron
I need to run a php file every one hour. Is there any other solution apart from cron job?

Required to login help
I'm trying to set up my site so users have to be logged into the forum to access the site.I've been

Multiple Pages
Hi. Im very new to php. I'm trying to create a basic login/registration page.

So I have a bas

error checking breaking my code
Hi there, OK first of all, big apologies for what I assume is really fundamental errors in the struc

pull content
I have an existing page, domain/adverts.php which has a good PR. I've just rebuilt my site and the n

Limiting checkboxes?
Hi guys,

I have this code: Code: if(isset($_POST['selected'])) {
foreach($_POST['selec

Business Health Check
Hello

I need to create an online business health check for a client it will be multiple choi

Cron Job and Output
I have php codes running under a cron job.
But everytime i output (echo) , it comes out as comple

Sign up to write
Sign up now if you have flare of writing..
Login   |   Register
Follow Us
Indyaspeak @ Facebook Indyaspeak @ Twitter Indyaspeak @ Pinterest RSS



Play Free Quiz and Win Cash