What happens is that I'm doing a query to an IINFORMIX database and the field is of the DATETIME type with Format (year to fraction (3)). I clarify that the format I can not modify.
Currently I have this function:
function validateDate($date, $format = 'Y-m-d H:i:s'){
$d = DateTime::createFromFormat($format, $date);
return $d && $d->format($format) == $date;
}
and I made the validation in this way:
foreach ($value as $key1 => $value1) {
$array[$key1] = ( validateDate($value1, 'Y-m-d H:i:s.v' ) == 1 )? conver_date($value1,'d-m-Y H:i:s') : $value1;
}
But it does not work for me, the function works, the problem is the format to validate the date, I was reviewing the documentation but I do not find how, the date that comes from the database is this: 2017-06-28 10: 33: 31.033
Now if I execute
foreach ($value as $key1 => $value1) {
$array[$key1] = ( validateDate($value1, 'Y-m-d H:i:s.033' ) == 1 )? conver_date($value1,'d-m-Y H:i:s') : $value1;
}
It works for me but only with dates that end in .033