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

前端 未结 6 640
庸人自扰
庸人自扰 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:30

    var culture = new CultureInfo( "en-GB" );
    var dateValue = new DateTime( 2011, 12, 1 );
    var result = dateValue.ToString( "d", culture ) );
    

提交回复
热议问题