After the code is executed, you can browse to a Document library to check a datetime column, for instance, Modified. It shows the datetime in the time zone you set.
However this is reported not working any more with SharePoint 2013. The reason is that SharePoint 2013 sets default value of User Profile property “
” to false, which is true in SharePoint 2010. You need first to set the property to true like this:
using (SPSite ccSite = new SPSite(siteURL))
If you execute the Code1 immediately after Code2 you will find that the user still see datetime column value (e.g. Modified) in old time zone.
This is because the timer job “
User Profile Service Application - User Profile to SharePoint Language and Region Synchronization
” (scheduled for 1 minute interval) has not completed yet. Setting ["SPS-RegionalSettings-Initialized"].Value to true will cause synchronizing language and region information from the User Profile service application to SharePoint users.
To set a time zone for a user on a site, first run Code2, set some time delay to allow timer job “User Profile Service Application - User Profile to SharePoint Language and Region Synchronization” to complete synchronization and then run Code1.