Jump to content

Datepicker outputs date in wrong format


tuke
 Share

Recommended Posts

I'm trying to build a date input field with following functionality:

- Date can be manually typed using format dd.mm.yyyy

- Date can be selected using datepicker (which should output the date in dd.mm.yyyy format)

The problem is that the date field only accepts dashes (-) as a separator so the date must be entered using format mm-dd-yyyy. Also, when a date is selected using datepicked, it is outputted in mm-dd-yyyy format.

How can I change the format to dd.mm.yyyy? I tried to change the format settings but it had no effect.

My settings:

post-867-0-80675400-1366136223_thumb.png

post-867-0-47378400-1366136224_thumb.png

I'm using Processwire 2.3.0.

EDIT: The datepicker works correctly in admin section but not in my front-end custom page.

Link to comment
Share on other sites

I've just tested and it works fine for me (English version). In the input field settings, it says that what is in the Date Input Format Code is automatically build from the date select above, unless you modify it. I have played with modifying it myself and letting PW do it for me and it still works...It accepts dots, dashes, slashes...Not sure  why it's not working for you..

Link to comment
Share on other sites

For some reason it is not working in my installation. The input field is generated using:

$field = $modules->get("InputfieldDatetime");
$field->label = "Aika";
$field->attr('id+name','time');
$field->required = 1;
$form->append($field); // append the field

And it outputs:

<input id="time" class="InputfieldDatetimeDatepicker InputfieldDatetimeDatepicker3" name="time" type="text" size="25" value='' data-dateformat='yy-mm-dd' data-timeformat='' data-ts='0' data-ampm='1' />
Link to comment
Share on other sites

If I understand this correctly, the InputFieldDatetime.js javascript code reads the date format from the data-dateformat html property (as shown in the post above). Somehow the date-dateformat property is incorrect.

I also found out that the datepicker works correctly in admin section but not in my front-end custom page.

Link to comment
Share on other sites

jQuery UI datepicker has different date formats than in PHP and not compatible. Maybe it's that.



$field = $modules->get("InputfieldDatetime");
$field->label = "Aika";
$field->attr('id+name','time');
$field->required = 1;
$form->append($field); // append the field
 

Also I don't see any date formatting here...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...