0

I have a string datetime like this in fr-CA time : "16 août 1980".

How can i change this string to US time like "16 aug 1980" or "august 16 1980" using c#?

I need create a cultureinfo of this time?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
lamtacvu
  • 675
  • 1
  • 7
  • 14

1 Answers1

4

Yes, you need to specifiy the cultureInfo. In this case, you can use DateTime.ParseExact like so :

var myDate = "16 août 1980";
var dateConverted = DateTime.ParseExact(myDate, "D", CultureInfo.GetCultureInfo("fr-CA"));
var dateUs = dateConverted.ToString("MMMM dd, yyyy", CultureInfo.GetCultureInfo("en-US"));
Kinetic
  • 2,640
  • 17
  • 35