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.

Did you know?Explore Trending and Topic pages for more stories like this.
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.
No comments posted yet

Your Answer:

Login to answer
70 Like 7 Dislike
Previous forums Next forums
Other forums

How would I protect......
I have a from, actually, a good amount of forms. How can I make it so you can't type the characters:

Material xxx does not exist in plant xxx
Dear All,

I am working for a steel project which is repetitive manufacturing.

email form (cannot find the problem)
Hello there. I've been having trouble with an email form. Can't find the problem really. I've tested

Variable passed to each() is not an array or object
Hi,

This is a email a friend type of form, and it isn't working anymore.

<?

Displaying image pathname instead of image
Hello

Im trying to upload and then display images from a mysql database - Its only basic and

Using CSS to format MySQL query
Hi,

If i want to have a news page on my site, which displays all records of a table in descen

strtotime issue
Hey all,

I'm playing around with some code, and basically the idea is:

Person changes

Saving PHP output as a file
I wondered if anyone knows how to save the rendered output of a PHP script as a file?

I have

help me fix these syntax errors...
I keep getting multiple syntax errors on this script like this one:

Parse error: syntax error

use an array from 1 class in a second class
I have a class that adds data to an array

Then I have a second class and I need to check if t

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