todatetime() expects an input string formatted presumably in your given time zone's format. if you changed your user locale but didn't update the formatting of the string you're passing it, then most likely it's now getting a string that it doesn't understand the formatting for.
I can't give much more specific advice than that since you haven't included your actual code and haven't included the source for the date/time string you're trying to pass into "todatetime()", both of which are important for figuring out what you'd need to change here.