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

The control with ID 'ace' requires a ScriptManager on the page
I'm trying to add a simple AlwaysVisibleControlExtender to my page, but it's not working. I get the

Query issues
I probably have this setup wrong well I know I do because nothing is showing up now. What I want is

Login page problems
I developed a website a few months ago and I am now having an issue with logging into it. The place

php + mysql count consecutive data
I have a database of values and I want to work out how to display them if the values match a consecu

UPLOAD IMAGES NOT WORKING!
Hi there i have a upload script in which it uploads the picture to a folder than creates two thumbna

Problem with PHP/mySQL login code
Hello,

There is an error in my login script and I can't figure out what it is...
I believe

problem when runing a funciton
I am trying to connect to database using a funciton in a functions.php

<?php
funct

want a code for uploading and downloading
i m trying to upload and download to my site..i need upload and download code ...i use a code for up

regex for quoted text within a string
I am still getting the hang of regex expressions, but I cant seem to figure out how I would escape q

Calander Basic Spript help
hi, just starting out with PHP and have the following script:

<?php
//This gets 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