-1

I'm trying to translate a Date in the current system language, this is my date: 2018/01/01, I tried to achieve my goal in this way:

var date = DateTime.ParseExact("2018/01/01", "dddd MMMM yyyy", new CultureInfo("it-IT")).ToString();

unfortunately I get:

System.ArgumentNullException

The InnerException say:

String not recognized as a valid DateTime value.

I used ParseExact to avoid this error, what I did wrong?

rene
  • 41,474
  • 78
  • 114
  • 152
MrFantastic
  • 87
  • 10

1 Answers1

1

Use this code it will work.

var date = DateTime.ParseExact("2018/01/01", "yyyy/MM/dd", new CultureInfo("it-IT"));

I think you now know the error reason. Thanks

Subash Kharel
  • 478
  • 1
  • 3
  • 12