如果您的输入是string(而不是a DateTime),那就是您的ToString通话无效的原因.您只需要先解析它,然后格式化结果值:
// I'll be honest: I don't really know if this is the "right" choice or not.
// Maybe someone else can weigh in on that.
IFormatProvider formatProvider = CultureInfo.InvariantCulture;
DateTime date = DateTime.ParseExact("01/30/2011", "MM/dd/yyyy", formatProvider);
string converted = date.ToString("yyyy-MM-dd");
Run Code Online (Sandbox Code Playgroud)