FormatDate in Display Item Form Webpart
Posted
by H(at)Ni
on Geeks with Blogs
See other posts from Geeks with Blogs
or by H(at)Ni
Published on Mon, 07 Mar 2011 10:46:49 GMT
Indexed on
2011/03/07
16:11 UTC
Read the original article
Hit count: 296
I've faced an issue that I wanted to display the date in the format of ('MMMM dd') that is retrieved from a sharepoint list in an arabic site collection.
So, after googling this issue, I've found out that a possible solution to my poblem is using the function ddwrt:FormatDateTime that can be used as long as you'll include the following namespace
xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"
My purpose was solved by writing this line of code in my xsl code behind for the webpart :
ddwrt:FormatDateTime(string(@StartDate),3073,'MMMM dd') but that worked only if the webpart is inserted into an English site .
After trying to search but in vain, I started to use my guesses that ended up doing something like that:
ddwrt:FormatDateTime(ddwrt:FormatDateTime(string(@StartDate),3073,'dd/MM/yyyy'), 3073, 'MMMM dd')
And the cause of the problem was that sharepoint parses the date as 'MM/dd/yyyy' which I think could be related to server regional settings, so I had to force it to parse the date in arabic-Egypt format as 'dd/MM/yyyy' in order to get the correct 'Month Day' format as expected.
© Geeks with Blogs or respective owner