This program uses the DateTime
struct from the System
namespace to represent a specific date and time.
The Now
property of the DateTime
struct returns a DateTime
object that represents the current date and time on the local computer. The program prints this object to the console using the WriteLine
method.
The output of this program will be the current date and time in a specific format, such as “1/8/2023 12:34:56 PM”.
The exact format will depend on the regional settings of the computer.
1 2 3 4 5 6 7 8 9 10 11 12 |
using System; class Program { static void Main() { DateTime currentTime = DateTime.Now; Console.WriteLine(currentTime); } } |
Output:
1 2 3 |
The Local Time is : 10/22/2022 19:03:03 PM |