Date conversion

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

+3
source share
2 answers

Do you already have this DateTime? If so, easy:

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

This will use the current flow culture - you can use a specific culture or an invariant culture, for example.

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

Note that "es" was escaped here, as otherwise it would use a culture date separator character. Another escaping option is to use a backslash, but then you need to either escape from this or use a string literal (assuming C # is due to your previous questions):

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

- :

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

Source: https://habr.com/ru/post/1755261/


All Articles