Alex Rivera | Logout

Parsing a string to "year-month-day" format in C#

Asked 2010-10-26T12:05:14.050
17

Im using a webservice that needs a datetime in the following format "2010-12-24"

I have the string to parse in the same "way" but as said, its a String.

string myDate = "2010-12-24";

How can i parse it so that it gets the same format?

Have tried using : DateTime.Parse(mystring);

but this gives me a colon separated format.

Edit
Report

1 Answer

4

DateTime time = DateTime.Now;
string format = "yyyy-M-d";
Console.WriteLine(time.ToString(format));

answered 2010-10-26T12:07:59.927

Your Answer