Success! Looks like we've fixed this one. According to our records the fix was applied for
TOUCH-1205
in
a recent build.
-
Sencha User
date format in template is not working
Hi,
I'm trying to format a date inside of a template:
Code:
{timestamp:date("d.m.Y")}
The timestamp field is defined as follows in the model:
Code:
{name: 'timestamp', type: 'date', dateFormat: 'c'},
Unfortunatly the date is not shown if i try to use the :date(format) function. Any ideas or is this a bug?
-
Sencha User
The following code works for me:
Code:
Ext.setup({
onReady: function() {
//defgine my model with the timestamp field
Ext.define('Model', {
extend: 'Ext.data.Model',
fields: [
{name: 'timestamp', type: 'date', dateFormat: 'c'}
]
});
//create a new instance of that model with a fake timestamp
model = Ext.create('Model', {
timestamp: '2004-02-12T15:19:21+00:00'
});
//show it in a new component using tpl + data
Ext.Viewport.add({
tpl: 'The timestamp is: {timestamp}',
data: model.data
});
}
});
Some points:
- Check your server is outputting the correct response.
- Ensure your model has the proper value
-
Sencha User
Hi,
this is also working for me. Please try to add a date format inside of the template.
Try the following code:
Code:
Ext.Viewport.add({
tpl: 'The timestamp is: {timestamp:date("d.m.Y")}',
data: model.data
});
-
Sencha User
Ah, sorry. I misread your post.
This is a bug. A quick fix is to open sencha-touch-all-debug.js and go to line 15121. You should see a line like this:
Code:
return v.dateFormat(format || Ext.util.Format.defaultDateFormat);
Replace it with this:
Code:
return Ext.Date.format(v, format || Ext.util.Format.defaultDateFormat);
-

Originally Posted by
testvogel
Hi,
I'm trying to format a date inside of a template:
Code:
{timestamp:date("d.m.Y")}
The timestamp field is defined as follows in the model:
Code:
{name: 'timestamp', type: 'date', dateFormat: 'c'},
Unfortunatly the date is not shown if i try to use the :date(format) function. Any ideas or is this a bug?
Formatting like this now works in PR4. The Ajax example uses this style.