For various purposes we need to find out the last modified date of a site e.g.-to find the recently visited sites, to find top sites etc. We can find it easily by using site.LastItemModifiedDate.
But the problem in this is that the actual modified datetime and the datetime shownby site.LastItemModifiedDate will not be same.
using (SPSite siteCollection = new SPSite("siteurl")) { SPWebCollection sites = siteCollection.AllWebs; foreach (SPWeb site in sites) { DateTime dt = site.RegionalSettings.TimeZone.UTCToLocalTime(site.LastItemModifiedDate); Console.WriteLine("site::::{0} Modified time::::{1}", site.Title, dt.ToString()); } }
This will give the exact modified DateTime of the site.