How to Change Date Format from Friendly to Standard in SharePoint?

Problem: After migrating to SharePoint 2016, all date columns changed to “Friendly” format! That is, instead of the exact date, date fields started showing values such as “2 days ago”, “About a minute ago”, “3 hours ago”, “Today at 3:00 PM”, etc.

How to Change the Display Format from Friendly to Standard in SharePoint?

To change the date field to show the date time in the standard format, do the following:

  1. Go to List settings >> Pick the Field to get the Field settings.
  2. You can switch the format from Friendly to Standard mode.
    sharepoint 2016 change friendly date format

PowerShell to Disable Friendly Display Format in SharePoint Date Columns

Let’s disable the friendly date format in all date columns of a SharePoint list using PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Config variables
$SiteURL="https://intranet.crescent.com"
$ListName="Projects"

#Get the List from the web
$Web = Get-SPWeb $SiteURL
$List = $Web.Lists[$ListName]

#Loop through each list field
ForEach($Field in $List.Fields)
{
    #Pick Date Columns
    If($Field.Type -eq "DateTime")
    {
        #Disable Friendly Display format
        $Field.FriendlyDisplayFormat="Disabled" #Relative
        $Field.update()               
        Write-Host -f Green "`t `t Field Updated:"$Field.Title
    }
}

Change Friendly Date Format to Standard in All Date Columns of a Site Collection:

Let’s change the friendly date format to standard date format in all date columns of all lists and libraries in a SharePoint site collection using PowerShell.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Set Site Collection variable
$SiteURL="https://intranet.crescent.com"

#Get All Webs of the Site Collection
$WebColl = Get-SPSite $SiteURL | Get-SPWeb -Limit All
 
#Iterate through each web
Foreach($Web in $WebColl)
{
    Write-host -f Yellow "Processing Web:"$Web.Url

    #Get All Lists of the web
    $ListColl = $Web.Lists

    #Loop through each list 
    Foreach($List in @($ListColl))
    {
        Write-Host -f Yellow "`t Processing List:" $List.Title
        
        $ListFields = $List.Fields
        #Loop through each field
        ForEach($Field in @($ListFields))
        {
            #Get the Field to suppress "Collection was modified" Error
            $Column = $List.Fields.GetFieldByInternalName($Field.InternalName)

            #Pick Date Columns
            If($Column.Type -eq "DateTime")
            {
                Write-Host -f Green "`t `t Field Updated:"$Column.Title

                #Disable Friendly Display format
                $Column.FriendlyDisplayFormat="Disabled" #Relative
                $Column.update()               
            }
         }
     }
}

PnP PowerShell to Disable Friendly Date Format in SharePoint Online

Use this PnP PowerShell script to disable friendly date format in SharePoint Online:

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
$ListName = "Projects"
$FieldName = "Modified" #Internal Name

#Connect to SharePoint Online site
Connect-PnPOnline -Url $SiteURL -Interactive

#Disable Friendly Date Format
Set-PnPField -List $ListName -Identity $FieldName -Values @{FriendlyDisplayFormat = [Microsoft.SharePoint.Client.DateTimeFieldFriendlyFormatType]::Disabled}

How about updating all Date and Time fields in all lists and libraries in a site collection?

#Parameters
$SiteURL = "https://crescent.sharepoint.com/sites/Retail"
   
#Get Credentials to connect  
#$Cred = Get-Credential

#Connect to PnP Online  
Connect-PnPOnline -Url $SiteURL -Credentials $Cred  

#Get All Webs from the site
$Webs = Get-PnPSubWeb -Recurse -IncludeRootWeb

#Iterate through each web
ForEach($Web in $Webs)
{
    #Connect to web
    Connect-PnPOnline -Url $web.URL -Credentials $Cred
    Write-host -f Yellow "Processing Web:"$Web.URL
    
    #Get all lists and libraries of the web
    $Lists = Get-PnPList | Where {$_.Hidden -eq $false}
    ForEach($List in $Lists)
    {
        Write-host -f Yellow "`tProcessing List:"$List.Title
        
        #Get All Date Fields
        $Fields =  Get-PnPField -List $List | Where {$_.Hidden -eq $false -and $_.FieldTypeKind -eq "DateTime"}
        ForEach($Field in $Fields)
        {
            #Disable the modified column friendlyformat  
            Set-PnPField -List $List -Identity $Field.InternalName -Values @{FriendlyDisplayFormat = [Microsoft.SharePoint.Client.DateTimeFieldFriendlyFormatType]::Disabled}
            Write-host -f Green "`t`tUpdated Display Format for Field:"$Field.Title
        }
    }
}

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “How to Change Date Format from Friendly to Standard in SharePoint?

  • Hi, Can we do this in SharePoint Online

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *