How to convert a Datetime string to a current culture datetime string

前端 未结 6 643
庸人自扰
庸人自扰 2020-12-03 06:41

I have string say \"12/1/2011\" in English US culture my current machine culture is English Uk which is \"dd/mm/yyyy\" format. How to convert the 12/1/2011 to 1/12/2011. I h

6条回答
  •  一个人的身影
    2020-12-03 07:31

    DateTime dateValue;
    CultureInfo culture = CultureInfo.CurrentCulture;
    DateTimeStyles styles = DateTimeStyles.None;
    DateTime.TryParse(datetimestring,culture, styles, out dateValue);
    

提交回复
热议问题