Aug
5
Written by:
Alejandro Quiroga Alsina
8/5/2008 12:11 PM
DotNetNuke displays the current date using a standard LongDateString formatting. It often happens that the user would have preferred another way to display the current date, but the standard customization provided by .NET sometimes is just not the best solution.
After investigating a little the CURRENTDATE skin object, I have found that it is not really difficult to display the current date in any format.
In order to format the date the way you want, you only need to edit the file "CurrentDate.ascx.vb", which is stored inside the "~/Admin/Skins" directory.
Inside that file, look at the following code (and modify it to suit your needs):
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' public attributes
If CssClass <> "" Then
lblDate.CssClass = CssClass
End If
Dim objUserTime As New UserTime
' ---{ I have added the following 2 lines }---
Dim sMonth() As String = {"Jan", "Feb", "Mar", "Apr", _
"May", "Jun", "Jul", "Aug", _
"Sep", "Oct", "Nov", "Dec"}
lblDate.Text = objUserTime.CurrentUserTime.Day.ToString() _
+ ", " + sMonth(objUserTime.CurrentUserTime.Month - 1) _
+ ", " + objUserTime.CurrentUserTime.Year.ToString()
' ---{ I have commented the following 5 lines }---
'If DateFormat <> "" Then
' lblDate.Text = Format(objUserTime.CurrentUserTime, DateFormat)
'Else
' lblDate.Text = objUserTime.CurrentUserTime.ToLongDateString
'End If
End Sub
And that's it. Any comments/suggestions will be very welcome.
Tags:
2 comments so far...
Re: How to localize the Portal's Date
But What will happen when you upgrade to newer version. Will your changes in currendate.ascx lost? thanks mesut
By Mesut demir on
6/4/2010 9:06 AM
|
Re: How to localize the Portal's Date
Yes Mesut,
Changes will be lost upon your upgrade to a newer version. The file gets overwritten. The key to the solution in those cases is to keep a simple .txt file related to each DNN installation you may have.
Within that file you simply take notes of every change you make to your installation and/or portals. That may include changes to the web.config file, list of third party modules installed, changes to portal.css, changes to your skin (that override the default skin installation, and then this very change to currentdate.ascx.
Then, every time you perform an update over your site, you check this txt/log file, update it with new information, and correct anything there is to correct. This txt/log file is like a sailboat's logbook belonging to that DNN installation. It will help you recover the installation in case of a breakdown and backup recover situation.
This I do for every DNN installation I have running online (tenths of them).
Thank you for commenting and, please do post your feedback if you want to.
Best regards, Alejandro.
By Alejandro Quiroga Alsina on
6/4/2010 9:32 PM
|