Posts

Showing posts with the label DateTime

Regularizing the DateTime in SharePoint Calender List

Some times in SharePoint Calender while retrieving the datetime of event gives the datetime adjusted according to Local Time which infact leads to addition of the Time Zone Period to the Time. For Example : If an Event was set for 12/19/2013 01:00PM then while fetching the date it gives us 12/19/2013 06:30PM (+5:50) i.e Offset of IST. Thus in order to regularize the above occurance. We can use  SPTimeZone . LocalTimeToUTC Example usage of the code using (SPSite oSiteCollection = new SPSite( "http://localhost" )) { using (SPWeb oWebsite = oSiteCollection.AllWebs[ "Website_Name" ]) { SPRegionalSettings oRegionalSettings = oWebsite.RegionalSettings; SPTimeZone oTimeZone = oRegionalSettings.TimeZone; System.DateTime dtDateNew = new System.DateTime(2007, 7, 15, 9, 5, 30, 0); Console.WriteLine(oTimeZone.LocalTimeToUTC(dtDateNew).ToString()); } } Reference :  View Reference Note: Still finding out why this...