PDA

View Full Version : Convert date in UTC format before submitting to server



coooolmagic
8 Mar 2011, 2:31 AM
Hi All

I have a grid json store like this:

this.grdStore = this.createGridStore( 'employeeDrid',
[
{name: 'recordId', type:'int'},
{name: 'empId', type:'int'},
{name:'endDt',type:'date',dateFormat:'time'},
{name:'startDt',type:'date',dateFormat:'time'}
]
);


I want end and startDt field values to be converted in UTC format before It is submitted to the server. Some how can't think of correct way of doing this.

Can you please help me?

fabio.parra
9 Mar 2011, 4:51 AM
You can override function encodeDate (Ext.util.JSON.encodeDate), so when any data is enconded you can convert to utc. See original code:



this.encodeDate = function(o){
return '"' + o.getFullYear() + "-" +
pad(o.getMonth() + 1) + "-" +
pad(o.getDate()) + "T" +
pad(o.getHours()) + ":" +
pad(o.getMinutes()) + ":" +
pad(o.getSeconds()) + '"';
};