When you’re processing an event on the server you’ll often need to use the web’s regional settings for date and time rather than the server’s. Here’s a code snippet that was part of an ECB action that will allow you to do this:
using (SPWeb web = SPContext.Current.Web) {
DateTime dtToday = DateTime.Now;
DateTime regionDate = web.RegionalSettings.TimeZone.UTCToLocalTime(dtToday);
DateTime completedDate = Convert.ToDateTime(SPUtility.FormatDate(web, regionDate,
SPDateFormat.ISO8601));
}
Advertisement