Today I would like to share our experience about an apparently strange behavior that happened while validate a date string using the DateValidator class: the preamble is that we notice as the same date string has been successfully validated on our staging server whereas it fails on production server. The differences between the two machines are the php version (5.6.30-0+deb8u1 on staging and 7.0.19-1 on production) and the ICU version and ICU Data version (respectively 52.1 for both on the staging and 57.1 for both on production) having the same intl version (1.1.0).
Debugging the code we have noticed as the line of code that changed the result was:
$parsedDate = @$formatter->parse($value, $parsePos);
present inside the
method of the DateValidator class. On the staging server the parse method return an unix timestamp whilst in production it return false. So far we noticed as disabling the strict parsing setting for the IntlDateFormatter object
allows the correct parsing of the date string the way we want, however the awful truth is that we had to comment the setLenient() line of code in order to make it works but we would like to look for a better solution… we might need to extend the DateValidator class to fits our needs? There might be other better things to do to solve such issue?
Thanks in advance