Git Product home page Git Product logo

Comments (4)

vitmalina avatar vitmalina commented on August 16, 2024

Just finished date formats. You can download /js/w2ui.js or /js/w2ui.min.js to use it. Basically, you can use either standalone fields:

<input type="text" id="dt" value="11/5/1977"/>
<script>
    $('#dt').w2field({ type: 'date', format: 'dd/mm/yyyy' });
</script>

Or you can use it as part of the form

$('#form').w2form({ 
    name     : 'form',
    url      : 'server/post',
    fields: [
        { name: 'field_date', type: 'date', options: { format: 'Mon dd, yyyy' } },
        ...
    ]
});

Formats supported:

mm/dd/yyyy
mm-dd-yyyy
dd/mm/yyyy
dd-mm-yyyy
Mon dd, yyyy

from w2ui.

enovision avatar enovision commented on August 16, 2024

There is no simple thing a European dates. For example in the Netherlands you write 14/10/1963 for dd/mm/yy,
but in Germany they write it with dots (14.10.1963). So in the w2ui.js you need to add a bit more code to satisfy the Germans too:

    if (format.toLowerCase() == 'dd/mm/yyyy' || format.toLowerCase() == 'dd-mm-yyyy' || format.toLowerCase() == 'dd.mm.yyyy') {
        val = val.replace(/-/g, '/');
        val = val.replace(/\./g, '/');
        if (val.split("/").length != 3)
            return false;
        var month = val.split("/")[1];
        var day = val.split("/")[0];
        var year = val.split("/")[2];
        var obj = new Date(year, month - 1, day);
        if ((obj.getMonth() + 1 != month) || (obj.getDate() != day) || (obj.getFullYear() != year))
            return false;
        return true;
    }

Maybe it is a suggestion to add a config object to the w2ui where the date format can be set by the developer, with a method to update it dynamically at initation of w2ui. If you going to use the w2ui for f.e. Wordpress plugins you might want to use the date format from the Wordpress admin settings and then it would be nice that at initiation time of the w2ui driven admin panels you can adjust the date format that is shown to the user is in the format of the Wordpress setup of the user.

from w2ui.

mbahsomo avatar mbahsomo commented on August 16, 2024

if i used date format dd/mm/yyyy on unix is oke, but on windows is bad.
if date input = 30-09-2013 on post variabel = 29-09-2013
why ...... ????

from w2ui.

vitmalina avatar vitmalina commented on August 16, 2024

Possibly time zone issue. As you know unix time is in GMT.

from w2ui.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.