Get Current Date and Time in C#

We can use DateTime.Now to get the current date and time in C#. The DateTime class also provides several other properties and methods to work with DateTime in C#.

Step 1. Open Visual Studio.

Visual Studio

Step 2. Click Console Application and click the OK button.

Console Application

Step 3. Type the program to see the current date and time in the program list.

using System;  
using System.Collections.Generic;  
using System.Linq;  
using System.Text;  
using System.Threading.Tasks;  
namespace Time {  
    class Program {  
        static void Main(string[] args) {  
            Console.Write("Current Date and Time is : ");  
            DateTime now = DateTime.Now;  
            Console.WriteLine(now);  
            Console.ReadLine();  
        }  
    }  
}  

Step 4. From the code, the output is given below.

Output

Here is a tutorial on working with Date Time in C#: