Anu

Anu

  • 1.6k
  • 200
  • 9k

DateTime ParseExact behaving differently

Oct 12 2023 10:35 AM

Hi,

I want to convert the date format from MM/dd/yyyy to yyyy-mm-dd in asp.net MVC. I tried the below two methods.

1)            DateTime dt2 = DateTime.Now;

               dt2 =DateTime.ParseExact(s, "MM/dd/yyyy HH:mm:ss", CultureInfo.InvariantCulture);

2)           DateTime dt2 = DateTime.Now;

               dt2= DateTime.ParseExact(s, "MM'/'dd'/'yyyy HH:mm:ss", null);

This is working in one server but not working on another server.  Please help me to resolve the issue


Answers (1)