为什么 SPList 的 LastItemModifiedDate 与列表中显示的修改日期不同?

发布于 2024-08-16 21:45:45 字数 394 浏览 4 评论 0原文

我有一个文档库,我正在以 SPList 的形式以编程方式访问该文档库。当我使用列表的 LastItemModifiedDate 属性时,返回的 DateTime 为 {1/7/2010 1:37:41 AM},但是当我浏览到文档库时 (使用我的网络浏览器)我可以看到最近的修改日期是7/01/2010 12:37 PM(这是我编辑文件时的正确本地时间) 。

在我看来,这像是一个时区问题,但我不确定 LastItemModifiedDate 从哪里获取其设置。

我需要更改什么才能使 LastItemModifiedDate 与浏览器中显示的时间一致?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

帝王念 2024-08-23 21:45:45

检查站点设置 =>区域设置=>时区。如果您使用给定的偏移量将当地时间转换为 GMT,它们是否匹配?

如果是,那么您可以尝试使用 SPWeb.RegionalSettings时区,然后使用 LocalTimeToUTCUTCToLocalTime 在时区之间进行转换站点和 UTC(请注意,在 SharePoint 上,您可以为每个站点提供自己的区域设置和时区)。

编辑:刚刚仔细检查,SPList.LastItemModifiedDate 始终是 UTC。我将在 MSDN 上发表评论

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文