DateFormat / getFormatter / setFormatter / validator

DateFormat / getFormatter / setFormatter / validator

LairdTurnerLairdTurner Posts: 7Questions: 3Answers: 0
edited August 2015 in Editor

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

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    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

  • LairdTurnerLairdTurner Posts: 7Questions: 3Answers: 0
    edited August 2015

    Hi!

    here the javascript part:

                        }, {
                            label: "Followup Date:",
                            name: "FollowupDate",
                            dateFormat: "d.m.Y"
                        }, {
    

    regards
    René

  • allanallan Posts: 63,523Questions: 1Answers: 10,473 Site admin

    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

  • LairdTurnerLairdTurner Posts: 7Questions: 3Answers: 0

    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é

This discussion has been closed.