作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
SPListItem.GetFormattedValue 似乎对 DateTime 字段有一个奇怪的行为。
它通过 SPListItem 的索引器检索 DateTime 值,根据此 MSDN article返回本地时间。
这是 Reflector 的片段
public string GetFormattedValue(string fieldName)
{
SPField field = this.Fields.GetField(fieldName);
if (field != null)
{
return field.GetFieldValueAsHtml(this[fieldName]);
}
return null;
}
最佳答案
在调用 GetFieldValueAsHtml 之前将日期转换回通用时间工作得很好。
DateTime localTime = (DateTime)item["DueDate"];
// this is local time but if you do localDateTime.Kind it returns Unspecified
// treats the date as universal time..
// let's give it the universal time :)
DateTime universalTime = SPContext.Current.Web
.RegionalSettings.TimeZone.LocalTimeToUTC(localTime);
string correctFormattedValue =
item.Fields["DueDate"].GetFieldValueAsHtml(universalTime);
关于sharepoint - MOSS 2007 : SPListItem. DateTime 字段的 GetFormattedValue 有错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/277640/
我正在处理一个使用 MPAndroidChart 库的项目,这让我非常抓狂,我想删除它。 问题是我创建了一个自定义的 ValueFormatter,但我无法理解这些值的来源,所有这些都是错误的。 p
检查其中一个应用程序的代码,发现这一行: out.print(context.getFormattedValue(context.webRoot(),null)); 我试图通过 Google 找到方法
我想从 Google Sheet 中的表格中获取以下格式的值 January 2008 [%M %Y] 现在我有了 JavaScript 代码来获取这样的值(这是在 google geochart 中
SPListItem.GetFormattedValue 似乎对 DateTime 字段有一个奇怪的行为。 它通过 SPListItem 的索引器检索 DateTime 值,根据此 MSDN arti
我是一名优秀的程序员,十分优秀!