Author Topic: How do I print current date and time in C#?  (Read 1183 times)

administrator

  • Administrator
  • Full Member
  • *****
  • Posts: 69
How do I print current date and time in C#?
« on: October 24, 2011, 12:26:43 pm »
You can System.DateTime.Now to get the current date and time (local time on your machine).

string currentTime = System.DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
System.Console.WriteLine(currentTime);

The above lines would print like,

2011/10/24 12:26:55

 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1