Why is SPList's LastItemModifiedDate not the same as the modified date shown in the list?
I have a document library that I am accessing programmatically as an SPList
. When I use the LastItemModifiedDate
property of the list, the DateTime returned is {1/7/2010 1:37:41 AM} but when I browse to the document library (with my web browser) I can see the most recent modified date is 7/01/2010 12:37 PM (this is the correct local time when I开发者_开发知识库 edited the file).
This looks to me like a timezone issue, but I'm not sure where LastItemModifiedDate
is getting its settings from.
What do I need to change so that LastItemModifiedDate
and the time appearing in my browser agree?
Check Site Settings => Regional Settings => Time Zone. If you convert your Local time to GMT using the given offset, to they match?
If yes, then you can try getting the Time Zone for the Site using SPWeb.RegionalSettings.TimeZone and then either use LocalTimeToUTC or UTCToLocalTime to convert between the timezone of the site and UTC (Note that on SharePoint, you could give each Site it's own regional settings and TimeZone).
Edit: Just double checked, SPList.LastItemModifiedDate is always UTC. I'll leave a comment on MSDN.
精彩评论