kevinjset
3 Feb 2012, 1:34 PM
Hello, I have a question regarding filtering date format. Below are three pieces of code, my model, store, and a piece of code from the view that uses both model and store.
Model
Ext.regModel('MyModel', {
idProperty: 'IdNumber',
fields: [
{ name: 'IdNumber', type: 'string' },
{ name: 'dateFilled', type: 'date', dateFormat: 'c' },
// { name: 'dateFilled', type: 'string' },
],
validations: [
{ type: 'presence', field: 'IdNumber', message: 'please enter an Id number' }
]
});
Store
Ext.regStore('MyStore', {
model: 'MyModel',
data: [
{
IdNumber: "1171077",
// dateFilled: "Sat Jun 18 2011 07:58:31",
dateFilled: "2011-06-18T14:58:31.000Z",
},
],
sorters: [{
property: 'IdDateDescription',
direction: 'ASC'
}],
proxy: {
type: 'localstorage',
id: 'notes-idDate-store'
},
getGroupString: function (record) {
if (record && record.data.drugDescription) {
return record.get('IdDateDescription');
} else {
return '';
}
}
});
App.stores.myStore = Ext.StoreMgr.get('MyStore');
and the other piece of code:
items: [
{
xtype: 'textfield',
name: 'dateFilled',
disabled: true,
label: 'Date Filled'
},
xtype: 'textfield',
name: 'rxNumber',
disabled: true,
hidden: true,
label: 'rxNumber',
id: 'rxNumber'
},
]
So basically, what I'm trying to do with my model and store is for "dateFilled" to display this date (in ISO 8601 format) "2011-06-18T14:58:31.000Z" into "Sat Jun 18 2011 07:58:31" and not "Sat Jun 18 2011 07:58:31 GMT-0700 (Pacific Daylight Time)", which is what it is outputting (the code where it outputs the dateFilled is in another javascript file (the third piece of code that includes the textfields is part of that file ). I'm using these two links as references for filtering my date format -> http://docs.sencha.com/touch/1-1/#!/api/Date and http://blog.stevenlevithan.com/archives/date-time-format . The thing is, I'm definitely able to output "Sat Jun 18 2011 07:58:31" if my "dateFilled" field is type: string (in my model), which is no problem; however, I'm required to have it type: date (in my model) and I have to use "2011-06-18T14:58:31.000Z" (in my store) no matter what... I've been trying to mess around with filtering out the date so that I can get "Sat Jun 18 2011 07:58:31" as my output with "2011-06-18T14:58:31.000Z" (in my store). I've tried several methods such as " { name: 'dateFilled', type: 'date', dateFormat: 'F j, Y, g:i a'}, " and " { name: 'dateFilled', type: 'date', dateFormat: 'mmmm d yyyy h:ss TT' } ", but they just show up blank when I try to output the date.
Anyway, thanks! Any help is appreciated!
Model
Ext.regModel('MyModel', {
idProperty: 'IdNumber',
fields: [
{ name: 'IdNumber', type: 'string' },
{ name: 'dateFilled', type: 'date', dateFormat: 'c' },
// { name: 'dateFilled', type: 'string' },
],
validations: [
{ type: 'presence', field: 'IdNumber', message: 'please enter an Id number' }
]
});
Store
Ext.regStore('MyStore', {
model: 'MyModel',
data: [
{
IdNumber: "1171077",
// dateFilled: "Sat Jun 18 2011 07:58:31",
dateFilled: "2011-06-18T14:58:31.000Z",
},
],
sorters: [{
property: 'IdDateDescription',
direction: 'ASC'
}],
proxy: {
type: 'localstorage',
id: 'notes-idDate-store'
},
getGroupString: function (record) {
if (record && record.data.drugDescription) {
return record.get('IdDateDescription');
} else {
return '';
}
}
});
App.stores.myStore = Ext.StoreMgr.get('MyStore');
and the other piece of code:
items: [
{
xtype: 'textfield',
name: 'dateFilled',
disabled: true,
label: 'Date Filled'
},
xtype: 'textfield',
name: 'rxNumber',
disabled: true,
hidden: true,
label: 'rxNumber',
id: 'rxNumber'
},
]
So basically, what I'm trying to do with my model and store is for "dateFilled" to display this date (in ISO 8601 format) "2011-06-18T14:58:31.000Z" into "Sat Jun 18 2011 07:58:31" and not "Sat Jun 18 2011 07:58:31 GMT-0700 (Pacific Daylight Time)", which is what it is outputting (the code where it outputs the dateFilled is in another javascript file (the third piece of code that includes the textfields is part of that file ). I'm using these two links as references for filtering my date format -> http://docs.sencha.com/touch/1-1/#!/api/Date and http://blog.stevenlevithan.com/archives/date-time-format . The thing is, I'm definitely able to output "Sat Jun 18 2011 07:58:31" if my "dateFilled" field is type: string (in my model), which is no problem; however, I'm required to have it type: date (in my model) and I have to use "2011-06-18T14:58:31.000Z" (in my store) no matter what... I've been trying to mess around with filtering out the date so that I can get "Sat Jun 18 2011 07:58:31" as my output with "2011-06-18T14:58:31.000Z" (in my store). I've tried several methods such as " { name: 'dateFilled', type: 'date', dateFormat: 'F j, Y, g:i a'}, " and " { name: 'dateFilled', type: 'date', dateFormat: 'mmmm d yyyy h:ss TT' } ", but they just show up blank when I try to output the date.
Anyway, thanks! Any help is appreciated!