Dates on different regional setting are wrong

Apr 5, 2013 at 1:10 PM
We are using a dutch SharePoint (english server with language pack / regional settings to dutch)

dates are getting twisted around: instead of day - month - year, batch edit will edit dates as month - day - year.

This means our dates are wrong, instead of 7th January we are getting 1st of July
Apr 5, 2013 at 2:37 PM
Edited Apr 5, 2013 at 2:38 PM
Solution on the reply above:
In the method UpdateListItem(SPListItem item) add following else if under the if where you check if the field is a taxonomyfield in the foreach loop:
else if (item.Fields[keyValue.Key].TypeAsString.StartsWith("DateTime", StringComparison.InvariantCultureIgnoreCase))
                            var field = item.Fields[keyValue.Key] as SPFieldDateTime;
                            if (field != null && item[keyValue.Key] != null)
                                CultureInfo ci = new CultureInfo(Convert.ToInt32(SPContext.Current.Web.Language));
                                DateTime fldValue = Convert.ToDateTime(keyValue.Value.ToString());
                                field.ParseAndSetValue(item, fldValue.ToString(ci.DateTimeFormat.ShortDatePattern, ci));
Now it work's for every language.
Apr 5, 2013 at 2:42 PM
Thanks for the snippet, I will make a new release this weekend based on it :).
Apr 5, 2013 at 2:43 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Marked as answer by appieschot on 11/13/2013 at 2:16 AM