Home »
C#
C# | DateTime.Day Property with Example
DateTime.Day Property: Here, we are going to learn about the Day Property of DateTime class with example in C#.
By IncludeHelp Last updated : August 27, 2023
C# DateTime.Day Property
DateTime.Day Property is used to get the day of the month from the date. It's a GET property of the DateTime class.
Syntax
int DateTime.Day;
Parameter(s)
- It does not accept any parameter.
Return value
The return type of this Property is int, it returns an integer i.e. day of the month.
Example to demonstrate example of DateTime.Day Property
using System;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
//creating an object of DateTime class
//and, initializing it with the current time
//using "Now"
DateTime dt = DateTime.Now;
//getting day of the month
string date = dt.Day.ToString();
//printing current date & time
Console.WriteLine("Current date & time is: " + dt.ToString());
//printing the day of the week
Console.WriteLine("Day of the month is: " + date);
//just to print a new line
Console.WriteLine();
}
}
}
Output
Current date & time is: 10/24/2019 6:59:06 AM
Day of the month is: 24