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 do I get the row number from from an sql table query
Hi all

I have a table that I query and it returns a number of rows.
mysql_num_rows($query)

Error querying database.
I get the above error when trying to insert some values to a datatable.
Here's the code :

Query output more than expected
$query=mysql_query("SELECT * FROM players, communities, divisions WHERE dob BETWEEN '{$start_da

Java API in PHP?
I have an application that we use internally here at the office.

The software company provide

My query is being run with no results.
I have this.

Code: function DropUser($duser_id, $user_email, $user_username) {

Breaking results into week blocks
I have a set of dates (and times), which are returned from a mySQL query.

These usually span

array_count_values question?
ok i'm trying to create a top ten list from a database of listed favorite movies.

the followi

Array help
Hello i got this code to fetch data from database but it is not working it displays
7
Array

Session
I am having a little trouble with a session. Not sure if it is my browser or what. I know I do not

Upload Code Help
Hi everyone I need some help with a bit of code ive been working with for a while. I am completely s

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