I would like to format a standard .NET DateTime
string as follows
2014-01-01 => Jan 2014
I can get the date form "January 2014" by using ToString("y")
but how can I abbreviate the month?
Is this even possible?
C# Visual Studio 2012 .NET 4.5
The MMMM format for months is the full name of the Month. For example -January, February, March, April, May, etc are the MMMM Format for the Month.
The international standard recommends writing the date as year, then month, then the day: YYYY-MM-DD. So if both Australians and Americans used this, they would both write the date as 2019-02-03.
Short format: dd/mm/yyyy (Day first, month number and year in left-to-right writing direction) in Afar, French and Somali ("d/m/yy" is a common alternative).
The T is just a literal to separate the date from the time, and the Z means “zero hour offset” also known as “Zulu time” (UTC). If your strings always have a “Z” you can use: SimpleDateFormat format = new SimpleDateFormat( “yyyy-MM-dd'T'HH:mm:ss).
You can use the MMM
format as in:
DateTime.Now.ToString("yyyy-MM-dd => MMM yyyy")
Which produces:
2014-08-06 => Aug 2014
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With