I have an item in a template of type date picker. I want to format it as a short date but it's coming out as a long date with formatAsDate set to true. I have the language of the site set to US English. How do I do this? Is there an Umbraco way, or do I need to wrap it in an ASP.Net tag?
I usually do my date formatting through XSLT files. Using the XSLT extensions, it's very easy to format dates any way you'd like to. Check out the wiki article about it.
When you use <umbraco:item> the date field is formatted according to the culture on the server. In the dialogue it also says that beneath the field where you set the date-formatting: "Format the value as a date, or a
date with time, accoring to the active culture."
So I guess you should be able to change it by changing the way the server serves the date. Otherwise I would use XSLT like Sebastian is suggesting.
Don't confuse active server culture with the final date format. 3/22/2010 (short date), March 22, 2010 (long date) are both acceptable formats within the English US culture.
In any case, the inline XSLT works for now. It would be good to have more conrtrol over that than just formatAsDate="true" in the future. Maybe just have the format string be a full up property instead of having to use XSLT.
Formatting an Item to short date
I have an item in a template of type date picker. I want to format it as a short date but it's coming out as a long date with formatAsDate set to true. I have the language of the site set to US English. How do I do this? Is there an Umbraco way, or do I need to wrap it in an ASP.Net tag?
Thanks.
I usually do my date formatting through XSLT files. Using the XSLT extensions, it's very easy to format dates any way you'd like to. Check out the wiki article about it.
I would hope I don't have to change it to XSLT just to get the date formatted. You shouldn't need code just to get an item on a page.
Is there a way to do this as I asked?
Thanks.
Hi Ed
When you use <umbraco:item> the date field is formatted according to the culture on the server. In the dialogue it also says that beneath the field where you set the date-formatting: "Format the value as a date, or a date with time, accoring to the active culture."
So I guess you should be able to change it by changing the way the server serves the date. Otherwise I would use XSLT like Sebastian is suggesting.
/Jan
You can do inline xslt if that's more to your liking.
http://umbraco.org/documentation/books/inline-xslt
You could try inline xslt:
Peter
Don't confuse active server culture with the final date format. 3/22/2010 (short date), March 22, 2010 (long date) are both acceptable formats within the English US culture.
In any case, the inline XSLT works for now. It would be good to have more conrtrol over that than just formatAsDate="true" in the future. Maybe just have the format string be a full up property instead of having to use XSLT.
Thanks
is working on a reply...