Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add literal strings in a DateTime format?

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.

like image 398
Maximus Decimus Avatar asked Oct 03 '13 15:10

Maximus Decimus


People also ask

What is string date/time format?

A date and time format string defines the text representation of a DateTime or DateTimeOffset value that results from a formatting operation. It can also define the representation of a date and time value that is required in a parsing operation in order to successfully convert the string to a date and time.

How do I convert a string to a datetime in Python?

We can convert a string to datetime using strptime() function. This function is available in datetime and time modules to parse a string to datetime and time objects respectively.

What is $@ in C#?

In C#, a verbatim string is created using a special symbol @. @ is known as a verbatim identifier. If a string contains @ as a prefix followed by double quotes, then compiler identifies that string as a verbatim string and compile that string.


1 Answers

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

Custom DateTime string formatting

like image 180
Darren Kopp Avatar answered Oct 10 '22 09:10

Darren Kopp