FIX: Setting the sharepoint regional settings and saving date values

Generally we are saving the date values by “DateTime.Now.ToString()” for the SharePoint list item fields. This works fine if our regional setting’s locale for the site is “English (United State)”. But if we change the locale to “English (United Kingdom)” and try to save the date by using the above method then it will throw the exception. To fix this just use “yyyy-MM-ddTHH:mm:ssZ” as the parameter to the “.ToString()” method for the datetime. So for example use DateTime.Now.ToString(“yyyy-MM-ddTHH:mm:ssZ”). This will save the value without any exception.

Related Posts

Leave a reply