user354547
user354547

Reputation: 775

Date conversion

How to convert the date displayed 7/19/2010 12:00:00 AM to July/Sunday/2010???

Upvotes: 3

Views: 159

Answers (2)

Jon Skeet
Jon Skeet

Reputation: 1500385

Do you already have this as a DateTime? If so, it's easy:

string text = dt.ToString("MMMM'/'dddd'/'yyyy");

This will use the thread's current culture - you can use a specific culture or the invariant culture, e.g.

string text = dt.ToString("MMMM'/'dddd'/'yyyy",
                          CultureInfo.InvariantCulture);

Note that the "/" has been escaped here, as otherwise it would use the culture's date separator symbol. Another option for escaping is to use a backslash, but then you need to either escape that or use a verbatim string literal (assuming C# due to your previous questions):

string text = dt.ToString(@"MMMM\/dddd\/yyyy");

Upvotes: 2

cjk
cjk

Reputation: 46425

Something like this:

 DateTime.Now.ToString(@"MMMM\/dddd\/yyyy");

Upvotes: 0

Related Questions