When we trying to retrieve item from PowerShell, when we tried to see the created and modified time of the item, it look different to what shown in the list item view in the SharePoint UI?
Why is it returning different time?
In PowerShell, when you try to get the file like the following:
$web = Get-SPWeb “http://…”
$file = $web.GetFile(“http://…/file.docx”) or foreach($file in $web.GetFolder(“folder name”).files) …
When we try to access the file “TimeLastModified” or “TimeCreated” property, it will return you a date time that is different than what you see in the list item UI?
Because it is returning the time adjusted in summer time format.
By using ToLocalTime() solves the problem, it will return time with adjusted time to our server time, like the following:
$file.TimeLastModified.ToLocalTime() and $file.TimeCreated.ToLocalTime()