Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting Date String abbreviating month

Tags:

c#

format

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

like image 496
Steven Wood Avatar asked Aug 06 '14 14:08

Steven Wood


People also ask

What is MMM in date format?

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.

How do you write the month name in a date?

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.

What is dd mm yy format?

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).

What is Z format date?

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).


1 Answers

You can use the MMM format as in:

DateTime.Now.ToString("yyyy-MM-dd => MMM yyyy")

Which produces:

2014-08-06 => Aug 2014
like image 62
Sina Iravanian Avatar answered Sep 24 '22 00:09

Sina Iravanian