Search code examples
javascriptodatasencha-touchsap-smp

How to define date type in Sencha Touch?


I am working in a Sencha Touch app, backend is running with SAP, and is sending in the json this odata string format '20140811'(for instance) if I define in the model this type nothing happens..

{
  name: "createdOn",
  type: "date",
  dateFormat: "DD-MM-Y"
}

How should I convert correctly Sap date format to Sencha type?


Solution

  • My solution was...

       {
        name: 'lastSurvey',
        type: 'auto',
        convert: function(date){
          var sNumber = date.replace(/[^0-9]+/g, ''),
            iNumber = sNumber * 1, //trick seventeen
            oDate = new Date(iNumber);
          return Ext.Date.format(oDate, 'd-m-Y');
        }
      },
    

    Opinions about this solution are welcome!