I put a custom Content Profile field with a Date type on my profile and registration page, and bound it to the ValidateAge module to check the age.
I get the following error messages when typing an invalid string, for example "asd":
warning: strtotime() expects parameter 1 to be string, array given in <mypath>/sites/all/modules/validateage/validateage.module on line 209.
warning: strtotime() expects parameter 1 to be string, array given in <mypath>/sites/all/modules/validateage/validateage.module on line 210.
warning: strtotime() expects parameter 1 to be string, array given in <mypath>/sites/all/modules/validateage/validateage.module on line 211.The reason is that I get the values from that field in this format:
'field_birth_date' => array ( 0 => array ( 'value' => array ( 'date' => 'asd', ), ), ),
BUT the code in the mentioned lines look like this:
$birthyear = date('Y', strtotime($edit[$fieldname][0]['value']));
$birthmonth = date('m', strtotime($edit[$fieldname][0]['value']));
$birthdate = date('d', strtotime($edit[$fieldname][0]['value']));
In my case, this isn't correct, since $edit[$fieldname][0]['value'] variable is an array type.
In my case, after correcting the original code to the following one works perfectly:
$datetime = '';
if( isset( $edit[$fieldname][0]['value']['date'] ) ){
$datetime = $edit[$fieldname][0]['value']['date'];
}
else{
$datetime = $edit[$fieldname][0]['value'];
}
$birthyear = date('Y', strtotime( $datetime ));
$birthmonth = date('m', strtotime( $datetime ));
$birthdate = date('d', strtotime( $datetime ));
But I think $edit[$fieldname][0]['value'] variable can possibly contain other types too, so a more complex check would be reasonable.
Thanks for your corrections in advance!