Do date conversion C#

Asked

Viewed 68 times

0

I have a date "Wed, Nov 25" and would like to convert it to 2015-11-25 How could I do that?

  • 1

    Do you only have one string, only with this content? You don’t have the year?

  • Exactly. Actually I have to get a date to display it in format 'qua, nov 25' then back it to date.

1 answer

0


string strData = "qua, nov 25, 2015";
CultureInfo provider = CultureInfo.GetCultureInfo("pt");
string formato = "ddd, MMM dd, yyyy";
DateTime data = new DateTime();
DateTime.TryParseExact(strData, formato, provider, DateTimeStyles.None, out data);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.