This works fine on the server, where I have an English version of sql server.
It throws an error however on my local development machine where apparently I have another language version of sql server.
So the only way I can prevent a FormatException being thrown on my development machine is by testing with dates where month and day are interchangeable (like 3/5/2012, 6/7/2013 etc ...)
date parsing error after upgrade 4.7.2 > 4.11.2.2
Hi Guys,
After upgrading my Umbraco site from version 4.7.2 to 4.11.2.2 this line of code throws an error:
jobnode.getProperty("jobStartsAt").Value = DateTime.Parse(datepicker.Text, provider);
It work fine before. After upgrading the umbraco.dll, cms.dll, businesslogic.dll I get this error when the above line of code is executed:
anyone has a clue what could be the problem?
your help is appreciated,
Anthony
got some further insight in this. Apparently it's caused by the en-Us dateformat (mm/dd/yyyy).
The error is thrown when I pick a date like 26th march 2013. Apparently 26/03/1013 is not recognized as a valid en-Us date.
Therefore I declared a variable holding the Culture info:
private CultureInfo provider = CultureInfo.GetCultureInfo(CultureInfo.CurrentCulture.Name);
then I pass the provider parameter to the Datetime.Parse() method like this:
jobnode.getProperty("jobStartsAt").Value = DateTime.Parse(datepicker.Text, provider);
This works fine on the server, where I have an English version of sql server.
It throws an error however on my local development machine where apparently I have another language version of sql server.
So the only way I can prevent a FormatException being thrown on my development machine is by testing with dates where month and day are interchangeable (like 3/5/2012, 6/7/2013 etc ...)
It's not a huge problem, but a bit annoying.
Wondering if there is a better solution for this.
greetings,
Anthony
is working on a reply...