Results 1 to 4 of 4

Thread: Date object without functions

  1. #1
    Sencha Premium Member
    Join Date
    Nov 2011
    Location
    Compiegne FRANCE
    Posts
    48

    Default Answered: Date object without functions

    Hello,

    I have to migrate an application from ExtJS 3 to 5.
    I currently using ExtJS 5.1.0.

    I have an issue with the Date object.
    1- DatePicker:
    I get the date, but I can not use the format methode of the date object
    Code:
            var dateField    =    new Ext.form.field.Date(
            {
                id                 :     'dateField'
                ,format        :      'd/m/Y'
                ,listeners        :    
                 {
                    change        :    function(field, d)
                    {
                        // Check if date value exist
                        if (typeof(d) === 'object')
                        {
                              var sDate    =    d.dateFormat ('d/m/Y');
                              // Return : TypeError: d.dateFormat is not a function (same with d.format)
                     }
               }
    2- Directly in the init component
    So, I have made some test, and that it's very surprising, in fact my date objects are not available:
    Code:
        ,initComponent    :    function()
        {
               var oDate    =    new Date();
               console.log(oDate); // Date {Wed Apr 22 2015 16:05:03 GMT+0200}
               var sDate    =    d.dateFormat('d/m/Y'); // TypeError: d.dateFormat is not a function
    I did not have make anythings on the original ExtJS 5.1.0, but it seems that I can not create a classical JavaScript object !!

    Have you got any idea? How I can check the Date object class declaration?

    Thank you very much for your help.

  2. Ext.Date is a singleton.
    use the following:
    Code:
    Ext.Date.format(d, 'Y/m/d')
    d is javascript date (in your case d or newValue)

  3. #2
    Sencha Premium User
    Join Date
    Jan 2014
    Location
    Fort Worth, TX, USA
    Posts
    64
    Answers
    2

    Default

    Where are you getting the method dateFormat from? Even without ExtJS there seems to be no such method. Try opening a blank window and entering these commands:
    Code:
    var bacon = new Date();
    typeof bacon.dateFormat
    Instead perhaps you can use Ext.Date.format() to do what you'd like.

  4. #3
    Sencha User yeghikyan's Avatar
    Join Date
    Mar 2009
    Location
    München
    Posts
    574
    Answers
    99

    Default

    Ext.Date is a singleton.
    use the following:
    Code:
    Ext.Date.format(d, 'Y/m/d')
    d is javascript date (in your case d or newValue)
    "The competent programmer is fully aware of the strictly limited size of his own skull; therefore he approaches the programming task in full humility, and among other things he avoids clever tricks like the plague." – Edsger W. Dijkstra

  5. #4
    Sencha Premium Member
    Join Date
    Nov 2011
    Location
    Compiegne FRANCE
    Posts
    48

    Default

    Hello, Thank you to both of you for your answers. I try Ext.Date.format(d, 'Y/m/d') and it's work. I understand that Ext.Date is now a singleton, I think it was not the case in Ext 3 (And in JavaScript in general). Thank you for your help.

Similar Threads

  1. [FIXED] Date not being passed to functions in Ext.Date.formatFunctions
    By chinabuffet in forum Sencha Touch 2.x: Bugs
    Replies: 1
    Last Post: 5 Jun 2012, 12:18 PM
  2. Object Date - To change view of the date pattern format
    By MarcusBulhosa in forum Ext 3.x: Help & Discussion
    Replies: 6
    Last Post: 3 Apr 2012, 10:42 AM
  3. date type in store is not stored as date object
    By keithhackworth in forum Ext:Bugs
    Replies: 0
    Last Post: 11 Aug 2011, 11:59 AM
  4. Adding functions to Object not work
    By elkidos in forum Ext 3.x: Help & Discussion
    Replies: 7
    Last Post: 17 Oct 2009, 9:40 AM

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
  •