Current Date And Time In C#

Step 1. Open Visual Studio.

Visual Studio

Step 2. Click Console Application and click OK button.

Console Application

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

  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.Linq;  
  4. using System.Text;  
  5. using System.Threading.Tasks;  
  6. namespace Time {  
  7.     class Program {  
  8.         static void Main(string[] args) {  
  9.             Console.Write("Current Date and Time is : ");  
  10.             DateTime now = DateTime.Now;  
  11.             Console.WriteLine(now);  
  12.             Console.ReadLine();  
  13.         }  
  14.     }  
  15. }  
Step 4. From the code, the output is given below-

output

 

Ebook Download
View all
Learn
View all