I have a GetFieldValueAsText converting DATETIME with 1 hour plus:
29/01/2014 14:26:45 after GetFieldValueAsText I get 29/01/2014 15:26
Someone can help me?
Thanks
I have a GetFieldValueAsText converting DATETIME with 1 hour plus:
29/01/2014 14:26:45 after GetFieldValueAsText I get 29/01/2014 15:26
Someone can help me?
Thanks
SharePoint internally stores dates in UTC format. I think your issue can be related to this:
The GetFieldValueAsText method requires that date and time values be in UTC format, while most SharePoint Foundation methods for returning list data return the values in local time. Consequently, when performing queries for list data, you need to convert time values to get expected results. To return items in UTC date and time, use an SPQuery object and set the DatesInUtc property to true
SPQuery query = new SPQuery();
query.DatesInUtc = true;
SPListItemCollection listItems = list.GetItems(query);
See more here: http://msdn.microsoft.com/en-us/library/ms442266.aspx
rather than using the spfield object to get the vaule do:
SPWeb web = SPContext.Current.Web;
SPList myList = web.Lists["My List"];
SPListItemCollection itemCollection = myList.Items;
foreach (SPListItem item in itemCollection)
{
DateTime dt = (DateTime)item["dateField"];
string showDate = dt.AddHours(1).ToString("dd-MMM-yyyy HH:mm:ss");
}