PDA

View Full Version : Format date in XTemplate



mitchellsimoens
23 Oct 2010, 6:45 AM
I'm trying to format a date within my XTemplate doing this:


new Ext.XTemplate(
'<tpl for=".">',
'<div>{end_date:date("Y")}</div>',
'</tpl>'
)

but it is still printing out the regular date object sting. I have searched for this and it seems that other people are using this so I'm confused.

Animal
23 Oct 2010, 8:33 AM
This works for me in the debugger:



new Ext.XTemplate('{foo:date("Y")}').apply({foo: new Date()})


It displays "2010" as expected.

Are you sure that each element of the Array the template is iterating over contains a property called "end_date" which is a Date object?