This isn't all of your code is it? Where are you defining $alert and what is it?
If $obj is an array then you need to delve into it to get the data you want.
If you're unsure of the format of the array use var_dump($obj) to view it on screen.
Well without a valid API key the call returns an error object which does not have a datetime property.
Obviously you don't want to post your API key but can you post what object you do get from the last var_dump? It needs to actually have a datetime property or you will get an error (if errors are enabled) and $cc will remain unset.