diff --git a/core/bulkchange.class.inc.php b/core/bulkchange.class.inc.php index d144f19c1..8161115e3 100644 --- a/core/bulkchange.class.inc.php +++ b/core/bulkchange.class.inc.php @@ -827,6 +827,8 @@ class BulkChange { $sFormat = $sDateFormat; } + $oFormat = new DateTimeFormat($sFormat); + $sRegExp = $oFormat->ToRegExpr(); if (!preg_match('/'.$sRegExp.'/', $this->m_aData[$iRow][$iCol])) { $aResult[$iRow]["__STATUS__"]= new RowStatus_Issue(Dict::S('UI:CSVReport-Row-Issue-DateFormat')); diff --git a/synchro/synchro_import.php b/synchro/synchro_import.php index 356f903b1..583dc9e47 100644 --- a/synchro/synchro_import.php +++ b/synchro/synchro_import.php @@ -217,15 +217,24 @@ function ReadMandatoryParam($oP, $sParam, $sSanitizationFilter) function ChangeDateFormat($sProposedDate, $sDateFormat) { // Make sure this is a valid MySQL datetime - $oDate = DateTime::createFromFormat($sDateFormat, $sProposedDate); - if ($oDate !== false) + $oFormat = new DateTimeFormat($sDateFormat); + $sRegExpr = $oFormat->ToRegExpr(); + if (!preg_match('/'.$sRegExpr.'/', $sProposedDate)) { - $sDate = $oDate->format(AttributeDateTime::GetInternalFormat()); - return $sDate; + return false; } else { - return false; + $oDate = DateTime::createFromFormat($sDateFormat, $sProposedDate); + if ($oDate !== false) + { + $sDate = $oDate->format(AttributeDateTime::GetInternalFormat()); + return $sDate; + } + else + { + return false; + } } }