How to add literal strings in a DateTime format?

Maximus Decimus picture Maximus Decimus · Oct 3, 2013 · Viewed 18k times · Source

Is it possible to add the word "at" between a Date and Time format? I tried to add it just like this "dddd, d MMM, yyyy at HH:mm" but the webapp is tranforming it into "aA" or "aP" depending of regional configuration CA or AU

Console.WriteLine(DateTime.Now.ToString("dddd, d MMM, yyyy at HH:mm"));

I forgot to say. I must be as a format string and no complex or concat functions.

Answer

Darren Kopp picture Darren Kopp · Oct 3, 2013

Yes, you need to escape the word by putting it in ' marks dddd, d MMM, yyyy 'at' HH:mm

Custom DateTime string formatting