Displaying Last Modified Date/Time for Pages in Themes

Overview

This article shares the process of displaying the last modified dates and times for pages in the DNN themes.


 

Process

  1. Log into your DNN instance.

  2. Navigate to the .ascx file of the theme: Portals/_default/Skins/<Theme Name>

  3. Open the file using a text editor.

  4. Place the following code at the end in the file and save it. 

    <script runat="server">
        Protected Function GetLastModifiedDate() As String
          Dim objTabController As New TabController
          Dim objTabInfo As DotNetNuke.Entities.Tabs.TabInfo = objTabController.GetTab(PortalSettings.ActiveTab.TabID, PortalSettings.PortalId, True)
          Return objTabInfo.LastModifiedonDate
        End Function
    </script>

    <h2>Last Modified: <%# GetLastModifiedDate %></h2>

 

Confirmation: The last modified date and time of the themes display in this format:
3/2/2020 8:24:46 AM 

 

Modifying the Date/Time Format

To display the date and time in a different format, modify the following code information: 

  • Replace Protected Function GetLastModifiedDate() As String in the code to Protected Function GetLastModifiedDate() As DateTime; and
  • Replace <h2>Last Modified: <%# GetLastModifiedDate %></h2> in the code to either of the following for different date and time formats as needed:
    • <h2>Last Modified: <%# GetLastModifiedDate.ToString("MMMM dd, yyyy | hh:mm tt") %></h2>;
    • <h2>Last Modified: <%# GetLastModifiedDate.ToString("MMMM d, yyyy | h:mm tt") %></h2>;
    • <h2>Last Modified: <%# GetLastModifiedDate.ToString("MMM d, yyyy | h:mm tt") %></h2>; or
    • <h2>Last Modified: <%# GetLastModifiedDate.ToString("M/d/yyyy | h:mm tt") %></h2>.

 

For example, the following code displays the last modified date and time in this format: Thursday, February 17 2020 | 21:30 

<script runat="server">
    Protected Function GetLastModifiedDate() As DateTime
    Dim objTabController As New TabController
    Dim objTabInfo As DotNetNuke.Entities.Tabs.TabInfo = objTabController.GetTab(PortalSettings.ActiveTab.TabID, PortalSettings.PortalId, True)
    Return objTabInfo.LastModifiedonDate
    End Function
</script>

<h2>Last Modified: <%# GetLastModifiedDate.ToString("dddd, MMMM dd yyyy | HH:mm") %></h2>

Note: For more information regarding the date and time formatting, refer to the DateTime.ToString Method article by Microsoft Support.

Comments

0 comments

Please sign in to leave a comment.