Get today's date in CSharp
Description
The following code shows how to get today's date.
Example
//w w w . j av a 2s .co m
using System;
public class Example
{
public static void Main()
{
// Get the current date.
DateTime thisDay = DateTime.Today;
Console.WriteLine(thisDay.ToString());
// Display the date in a variety of formats.
Console.WriteLine(thisDay.ToString("d"));
Console.WriteLine(thisDay.ToString("D"));
Console.WriteLine(thisDay.ToString("g"));
}
}
The code above generates the following result.