DNN setting the date format for the calendar control
Having recently been frustrated by the lack of support in DNN to change the format of dates (yes I know about the web.config setting and yes I know about the built in language settings - it still didn't work when using DataSprings DynamicForms module which otherwise is simply superb).
Anyway if you're experiencing the same issues that we did then there is a simple solution.
In the "js" folder you'll find a file named "PopupCalendar.js".
I won't bore you with the various ways in which you customise the look and feel but if you need to change the date format (in my case to the United Kingdom dd/mm/yyyy) here's how...
Simply scroll down until you find the lines:
//default localized short date format if not provided
if (popCalDstFmt == "")
popCalDstFmt = "m/d/yyyy";
This is where the date format is set if you didn't pre-specify a format on the call to the popupCal method.
You can simply override this by adding the following line straight after this function... In our case:
//force UK date format
popCalDstFmt = "d/M/yyyy";
...and voila you're ready to rock and roll!
Hope this helps some other frustrated developers!
Cheers
Jon
Anyway if you're experiencing the same issues that we did then there is a simple solution.
In the "js" folder you'll find a file named "PopupCalendar.js".
I won't bore you with the various ways in which you customise the look and feel but if you need to change the date format (in my case to the United Kingdom dd/mm/yyyy) here's how...
Simply scroll down until you find the lines:
//default localized short date format if not provided
if (popCalDstFmt == "")
popCalDstFmt = "m/d/yyyy";
This is where the date format is set if you didn't pre-specify a format on the call to the popupCal method.
You can simply override this by adding the following line straight after this function... In our case:
//force UK date format
popCalDstFmt = "d/M/yyyy";
...and voila you're ready to rock and roll!
Hope this helps some other frustrated developers!
Cheers
Jon
Labels: asp.net, calendar, dnn, dotnetnuke, javascript, web control





0 Comments:
Post a Comment
<< Home