[edit] C# DateTime Month Property
The DateTime month property simply returns the month part of a datetime object which will be between 1 to 12.
[edit] Syntax
int month = variable.Month;
[edit] Example
using System;
class Program
{
static void Main()
{
DateTime variable = DateTime.Now;
int month = variable.Month;
Console.WriteLine(month);
Console.Read();
}
}
Output:
4
When I ran this code it was in the month of April and of course April is the 4th month in the year.
<= DateTime Tutorial
|