So this could be modified to be a *little* bit more "diverse" assuming that regardless of device locality that the provided result is YYYY-MM-DD:
Code:
if (ACCOUNT_DOB == 'true') {
if (ENTRY_DOB_MIN_LENGTH > 0 or !empty($_POST['dob'])) {
if (DATE_FORMAT === 'm/d/Y') {
if (preg_match("/^([0-9]{4})(.)([0-9]{2})(.)([0-9]{2}$)/", $dob, $output_array)) {
$_POST['dob'] = substr($dob, 5, 2) . '/' . substr($dob, 8, 2) . '/' . substr($dob, 0, 4);
$dob = substr($dob, 5, 2) . '/' . substr($dob, 8, 2) . '/' . substr($dob, 0, 4);
}
} elseif (DATE_FORMAT === 'd/m/Y') {
if (preg_match("/^([0-9]{4})(.)([0-9]{2})(.)([0-9]{2}$)/", $dob, $output_array)) {
$_POST['dob'] = substr($dob, 8, 2) . '/' . substr($dob, 5, 2) . '/' . substr($dob, 0, 4);
$dob = substr($dob, 8, 2) . '/' . substr($dob, 5, 2) . '/' . substr($dob, 0, 4);
}
}
if (substr_count($dob,'/') > 2 || checkdate((int)substr(zen_date_raw($dob), 4, 2), (int)substr(zen_date_raw($dob), 6, 2), (int)substr(zen_date_raw($dob), 0, 4)) == false) {
$error = true;
$messageStack->add('create_account', ENTRY_DATE_OF_BIRTH_ERROR);
}
}
}
Although, modifications to the language(s) format would "necessitate" further update of the above logic.
It looks like the device is providing an ISO 8601 style date format which the above regex is looking at (excluding time and not requiring that the character between date numbers be a dash (-).
Bookmarks