Validator and Date is not in the expected format
Validator and Date is not in the expected format
This is simple editor field
{
"label": "Datum vzorčenja",
"name": "cert_vzo_par.datum",
"type": "datetime",
"opts": {
"format": "MM.YYYY"
}
}
This is validator
{
Field::inst('cert_vzo_par.datum')
->validator('Validate::dateFormat', 'm.Y')
->getFormatter('Format::date_sql_to_format', 'm.Y')
->setFormatter('Format::date_format_to_sql', 'm.Y'),
}
Everything works fine, for example, 02.2016, 02.2015, 02.2018, except when we are trying to enter 02.2017. Then the Date is not in the expected format
is shown. The only workaround is to remove ->validator('Validate::dateFormat', 'm.Y')
. I really don't know what is wrong with this February 2017 (02.2017). I guess it is something wrong with the validator function. I have checked the PHP date formatter and the correct syntax is 'm.Y'
Can you help?
This question has an accepted answers - jump to answer
Answers
Admin, please delete this question. I have found the problem. 02.2017 is converted into 01.03.2017. I'm going to change the field type from DATE to CHAR.
Thanks for posting back - good to hear you've got it fixed.
Rather than deleting the question, I'll mark it as answered if that's okay, since someone else might have a similar question and benefit from your answer.
Allan