SharePoint 2010 time zones setting programmatically

11. April 2012 04:00 by Rashid Aziz in Sharepoint blogs  //  Tags: , ,   //   Comments

The SharePoint 2010 server is always set to a specific time zone. Users from all over the world can change the time zone by using “My regional settings”. I wanted to achieve this programmatically as a batch operation.

To do this, I have used the following code.

SPRegionalsettings spRegnal= new SPRegionalSettings(web, true);
spRegnal.TimeZone.ID = 2 ;     // Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
User.RegionalSettings= spRegnal ;

The SPRegionalSettings takes two parameters, the SPWeb and a Boolean. Set the time zone ID and finally get the SPUser object and assign the regional settings to that user.

 

blog comments powered by Disqus

Stay connected

SharePoint Links

Month List