I am building an App using Sencha touch api. I have a 开发者_StackOverflow社区model
Ext.regModel('Task',
{fields: [{name:'TaskID', type:'int'},
{name:'DueDate', type:'date'},
{name:'ClientName', type:'string'},
{name:'TaskName', type:'string'},
{name:'AssignedTo', type:'string'}]
});
I recieve a date /Date(1304879400000)/
i.e Ajax serialized date. So how do i convert into readable date format. Any help would be appreciated.
Thanks
Use a converter in the model config:
fields: [
'id'
{
name: 'datetime',
type: 'date',
dateFormat: 'MS'
}
The above model has two fields: id and datetime, with datetime being parsed as a Microsoft serialised Ajax string.
See docs for dateFormat and the 'MS' format.
The number is the timestamp so you could parse it like:
date = new Date(parseInt(DueDate.substr(6)));
Where DueDate is your "/Date(1304879400000)/"
formatted string
精彩评论