In the example below, the ACTIVATION DATE column is converted to Database format and assigned to the Activation Date model field.
/* the conversion is surrounded with a try-catch to avoid throwing exceptions */
try{
/* a DateTime object is created from the format used in the import file */
$date = DateTime::createFromFormat('d/m/Y', $value);
/* the field 'cust_activation_date' is set with the created date formatted in the Database
accepted format */
$model->setCustActivationDate($date->format('Y-m-d'));
}
catch(Exception $exxx){
/* any exception is printed to the import_device.log log file, if the file doesn't exist
it will be created */
Deep::log($exxx,null,'import_device.log');
Deep::log('value: '.$value, null, 'import_device.log');
Deep::log('date: '.$date, null, 'import_device.log');
}