If current month is March and DateTime.Now.Month.ToString() returns 3. If you would like to get double digit format(03) instead of 3, use below code
DateTime.Now.ToString("MM")
(or)
DateTime.Now.Month.ToString("d2")
We will see an example for some other formats supported by month.namespace DotNetMirror
{
class DateTimeNowMonthFormatDemo
{
public static void Main()
{
//print double digit
Console.WriteLine(DateTime.Now.ToString("MM"));
Console.WriteLine(DateTime.Now.Month.ToString("d2"));
//other formats
DateTime dt = Convert.ToDateTime("13-9-2014"); //13th September 2014
Console.WriteLine(dt.ToString("M"));
Console.WriteLine(dt.ToString("MM"));
Console.WriteLine(dt.ToString("MMM"));
Console.WriteLine(dt.ToString("MMMM"));
Console.Read();
}
}
}
Output: