The Year Month format specifier represents a custom date and time format string.
It is defined by the DateTimeFormatInfo.YearMonthPattern property.
Here is the custom format string.
yyyy MMMM
using System; using System.Globalization; class Demo { static void Main() { DateTime date = new DateTime(2018, 9, 7, 7, 55, 20); Console.WriteLine(date.ToString("Y",CultureInfo.CreateSpecificCulture("en-US"))); } }
September 2018