View Single Post
Old 11-21-2012, 07:43 PM   PM User | #4
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,662
Thanks: 4
Thanked 2,452 Times in 2,421 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
The only way to really do that is to use a check now. Seems like you can have null entries in there (which I assume map to null not an empty datetime). This is why I hate it when external libraries seem to think they should be responsible for constructing objects.
You can use a ternary to check them:
PHP Code:
($result['DateEntered'] instanceof DateTime) ? $result['DateEntered']->format('Y-m-d H:i:s') : $result['DateEntered'
And do the same with the date updated. Not sure what it is otherwise, it could technically be an integer or simply null. So I just left it raw.
Fou-Lu is offline   Reply With Quote