Share via


SharePoint 2016: Set standard date to all DATETIME columns

Introduction

With a new installation of SharePoint 2016 you may or may not notice the modified date and created date display change. Personally a rather annoying change that I feel should be the default, but that's another story.

Anyway how do you change this if this is embedded into your farm? I've looked about on google but all the blogs I came across showed how to do it to a single column, which isn't what I wanted. PowerShell to the rescue.

Add-PSSnapin "Microsoft.SharePoint.Powershell"  -ErrorAction SilentlyContinue
$WebCollection = Get-SPSite "Site" -Limit All | Get-SPWeb -Limit All
 
foreach($site in  $WebCollection){
 
$lists = $site.Lists
 
foreach($list in @($lists)){
 
Write-Host "Connected to $list"  -ForegroundColor Yellow
 
foreach($field in  @($list.Fields)){
 
$column = $list.Fields[$field.Title]
 
    if($column.Type -eq "DateTime"){
                     
   Write-Host "Connected to "  $column.Title -ForegroundColor Yellow
   $column.FriendlyDisplayFormat = 1
   $column.update()
                
            }
        }
    }
}

You can also limit the list/library you want to do this on by using a where clause in the lists area like the following:

foreach($list in  $lists |?{$_.Title -like "*NAME HERE*"}){}

Conclusion

In this article, I discussed How to set the standard date to DATETIME columns