When the following gets bad data PHP aborts.
PHP Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct(): Failed to parse time string (980671) at position 4 (7): Unexpected character'
How can I catch this if the data is bad to take other action so the PHP problem doesn't fail?
$date = new DateTime($TRANSACTION_DATE_MMDDYY_raw);
As
@Rob W
already said, you gotta catch that exception.But what could cause that exception is inaproppriate datetime format.
To solve this, you could do instead:
More about it: http://www.php.net/manual/en/datetime.createfromformat.php
Use
try
andcatch