0

I have a Date value for example:

string date = "02/14/2015" //(MM/DD/YYY)

I want to convert it into ISO Date Format. Is there anyway to do this..

Mudasir Sahto
  • 69
  • 3
  • 13
  • this may help:http://stackoverflow.com/questions/114983/given-a-datetime-object-how-do-i-get-a-iso-8601-date-in-string-format – Ehsan Sajjad Mar 16 '15 at 05:50

3 Answers3

0

Use the DateTime.ParseExact(dateString, format, provider); function.

https://msdn.microsoft.com/en-us/library/w2sa9yss%28v=vs.110%29.aspx

Example:

CultureInfo provider = CultureInfo.InvariantCulture;
string date = "02/14/2015";
string format = "dd/mm/yyyy";

// Result is now a DateTime and can be easily converted
DateTime result = DateTime.ParseExact(date, format, provider);
Boren
  • 101
  • 4
0

try this:

string date = "02/14/2015"

DateTime NewDate= DateTime.ParseExact(dateString, "MM/DD/YYYY", 
CultureInfo.InvariantCulture);

string NewFmt=NewDate.ToString("yyyy/MM/DD");
Dgan
  • 10,077
  • 1
  • 29
  • 51
0

Try This...

string date = "02/14/2015";
DateTime d2 = DateTime.Parse(date, null, DateTimeStyles.RoundtripKind);
Nalaka
  • 1,165
  • 7
  • 12