Format DateTime in the form: "W E D N E S D A Y 9/11"

I am using .NET/C#. I have DateTime values I'm pulling from a DB. For a given DateTime value, I want the day formatted with a space between each letter of the day. Then I want two spaces, then I want a numeric month and day divided by a slash. Examples:

"W E D N E S D A Y   9/11"
"F R I D A Y   9/13"

The spacing on the lettering should ideally be done with StringBuilder or whatever so this doesn't suffer massive perf issues.

I'm sure I could hack this out myself but one of you geniuses know this straight off the top of your head, hmm?

Thanks much for any help you can offer.
LVL 6
kennethfineAsked:
Who is Participating?
 
jandromedaConnect With a Mentor Commented:
Well this is what I can come up with.
DateTime time = DateTime.Today;
			string monthAndDate = time.ToString("MM/dd");
			string day = time.DayOfWeek.ToString();
			
			char[] arr = day.ToCharArray();
			day = string.Empty;		
			
			foreach (char c in arr)
			{
				day = string.Concat(day, c.ToString(), " ");
			}
			
			Console.WriteLine(string.Concat(day, " ", monthAndDate));

Open in new window

0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.