DateFormat / getFormatter / setFormatter / validator
DateFormat / getFormatter / setFormatter / validator
Hi!
I want to store date format like this '22.10.2015'
So I've defined a validator with the appropriate get and set Formatter like this:
Field::inst('FollowupDate')
->validator('Validate::dateFormat', array(
"format" => "d.m.Y",
"message" => "Please enter a date in the format dd.mm.yyyy, for example '20.01.2015'"
))
->getFormatter('Format::date_sql_to_format', "d.m.Y")
->setFormatter( 'Format::date_format_to_sql', "d.m.Y"),
The Date will be shown correctly, but when I enter a date like '01.01.2015' everything works fine but if I enter a date like '10.01.2015' I will get '01.10.2015'.
And if I enter '31.12.2015' it won't save the date. Change the setFormatter to 'setFormatter( 'Format::date_format_to_sql', "m.d.Y")'
doen't work either. If I enter a date like '13.01.2015' the date flips to '01.01.2016'.
Have anyone an idea what a setting could solve this problem?
greets
René
Answers
Hi René,
Could you possibly also show me your Javascript configuration for this field? It needs to be told to expect data in the
d.m.Y
format.Thanks,
Allan
Hi!
here the javascript part:
regards
René
Is it jQuery UI you are using for the date picker? If so, their date syntax is not the same as PHPs - see the jQuery UI documentation. You would probably want to use
dd.mm.yy
for jQuery UI.Allan
Hi!
I only use a text field not a datePicker. I'm using in general jqueryUI. But if I use a datepicker it doesn't work either.
Not for 'dd.mm.yy' too.
-René