Jump to content
tuke

Datepicker outputs date in wrong format

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.

Share this post


Link to post
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..

Share this post


Link to post
Share on other sites

You should be able to pick that kind of date from dropdown. 8.4.2010

Share this post


Link to post
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' />

Share this post


Link to post
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.

Share this post


Link to post
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...

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By lenoir
      Hi,
      I've setup a date field with a date picker. I set it with a range of "-10:+10" for the years, but for some obscure reason (to me), instead of showing years from 2009 to 2029, it shows the coming 20 years (2019 - 2039). 
      Am I missing a preference somewhere?
    • By VeiJari
      Hello forum! 
      Our customer wants to choose only 15 minute intervals in the inputfield Datetime. So the dropdown values would be: 0, 15, 30 and 45.
      Is there an easy way to achieve this?
      Any help is appreciated 🙂
    • By Elchin
      Hi.
      I want select pages where now between date and end_date or now bigger than date and end_date is empty.
      I have five tried variants:
      $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("foo=(date<$start,date_end=''),bar=(date<$start,date_end>=$start),sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date<$start,(date_end='',date_end>=$start),sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date_end=''|date_end>=$start,date<$start,sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("!date_end|date_end>=$start,date<$start,sort=-date,limit=12"); $start = strtotime(date('Y-m-d') . " 00:00:00"); $results = $page->children("date_end>=$start|!date_end,date<$start,sort=-date,limit=12"); All this variants not worked for me and returned zero results.
    • By MateThemes
      Hello everyone.
      I have a question that i can't find a way to solve.
      I have following function in _uikit.php 
      $date = $page->get('date|createdStr'); $dateModified = $page->get('datemodified'); But I need to output the $date in to different formats.
      My further function looks like this
      // return the blog post article markup return " <div> <article class='uk-article blog-post $class'> <meta property='name' content='$page->title'> <meta property='author' typeof='Person' content='Arra Lifte Harmanschlag'> <meta property='dateModified' content='$dateModified'> <meta property='datePublished' content='$date'> <meta class='uk-margin-remove-adjacent' property='articleSection' content='News'> <div property='image' typeof='ImageObject'> $featuredBlogPostImage </div> $heading <ul class='mt25 uk-margin-remove-bottom uk-subnav uk-subnav-divider'> <li class='uk-article-meta'> <time datetime='$date'>$byline</time> </li> </ul> <div class='mt25' property='text'> $body </div> </article> </div> "; Now I need to output the meta property in this format 2019-03-02CET05:23:00 and then a normal date format that is displayed on the Homepage with 2. März 2019 without time.
      Can anybody help me?
      Thanks in advance.
    • By Eunico Cornelius
      I am trying to get the strftime format from the function convertDateFormat(). However, the output has $ signs in it which i cannot use in strftime.(example of conversion : $d/$m/%Y what strftime actually uses: %d/%m/%Y). Am I in the wrong here or is there some way to format strftime? Thank you in advance :).
×
×
  • Create New...