Quantcast
Viewing all articles
Browse latest Browse all 8156

Unable to parse the date in the format "M/d/yyyy H:m:s" using DateTime.ParseExact(String, String, IFormatProvider)

I am working on a windows phone silverlight application.I have a requirement where in I want to parse the date string of format "M/d/yyyy H:m:s" (eg: 3/18/2015 14:4:5) to DateTime struct.
This is what I tried:
     
     string dateString = "3/18/2015 14:4:5";
     string format = @"M/d/yyyy H:m:s";
     CultureInfo provider = CultureInfo.InvariantCulture;
     DateTime.ParseExact(dateString,format,provider);

But I am getting the following output:
03-18-2015 14:04:05

Required Output:
3/18/2015 14:4:5

I want the DateSeparator to be "/" and doesn't want an addition of extra '0' to any of the parameters like day,month,year,minutes etc to make it two digits.

Viewing all articles
Browse latest Browse all 8156

Trending Articles