Results 1 to 4 of 4

Thread: How to make the date type work with UK dates

  1. #1
    Sencha User
    Join Date
    Dec 2008
    Location
    Manchester, UK
    Posts
    114
    Answers
    4

    Default How to make the date type work with UK dates

    I'm supplying dates back to my model in UK format (the sensible day/month/year format :-) ).

    The field is set in the model as follows:

    { name: 'pubDate', type: 'date' },

    However, I receive the following warning:

    [WARN][Ext.data.Model#setData] Cannot parse the passed value (18/08/2014) into a valid date

    How can I make the model recognise UK dates?
    (the same model works fine in my ExtJS site)

  2. #2
    Sencha Premium User mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    40,448
    Answers
    3997

    Default

    You can use the dateFormat config and specify the format:

    Code:
    { name : 'pubDate', type : 'date', dateFormat : 'd/m/y' }
    Mitchell Simoens @LikelyMitch

    Check out my GitHub:
    https://github.com/mitchellsimoens

    Posts are my own, not any current, past or future employer's.

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    21
    Answers
    1

    Default

    How to apply this date format globally? Overriding config of Ext.data.Field is working for me but only in debug. When I build application it's not working anymore.

  4. #4
    Sencha User
    Join Date
    Aug 2011
    Posts
    21
    Answers
    1

    Default

    The most elegant way I've came up with:

    Code:
    Ext.define("App.override.data.Field", {
        override: "Ext.data.Field",
        
        getDateFormat: function() {
            return this.callParent() || "c";
        }
    });

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •