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: