DateTime in C# current Date and Time

DateTime in C# current Date and Time

In this DateTime example, we will see how to get current datetime of the system. You may require to get asp.net server time or stand alone windows application current system time. We will see both c#.net and Vb.Net examples. DateTime is a structure in assembly System.

C# program to get current time of the system
using System;
namespace DateAndTime.Example
{
class Program
{
static void Main(string[] args)
{
DateTime dt = DateTime.Now;
Console.WriteLine("Current time of the system in {0}",dt.ToString());
Console.ReadLine();
}
}
}
Vb.Net Get current time of the system example
Namespace DateAndTime.Example
Class Program
Private Shared Sub Main(args As String())
Dim dt As DateTime = DateTime.Now
Console.WriteLine("Current time of the system in {0}", dt.ToString())
Console.ReadLine()
End Sub
End Class
End Namespace
Date Time Example Date Time Example C# Output Current time of the system in 12/28/2011 9:25:35 PM

Description: DateTime.Now returns the current date and time of the system. It uses current culture information of the system. This example outputs the Today’s date and time. 

      

Tags:

C# DateTime DifferenceC# DateTimeDateTimeTryParse using C# and VB.net exampleC# Parse method of DateTimeC# DateTime ToString()Date Time in English United KingdomDateTime ParseExact Time 10:10:13 AM hh mm ss tt nullDateTime.Today Vs DateTime.NowDateTime format Time StringAsp.net Cache ObjectC#.net get tomorrows date

Author

My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in ASP.net year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.
 

I'm Satalaj.