Get today's date - CSharp Language Basics

CSharp examples for Language Basics:Date Time

Description

Get today's date

Demo Code

using System;//from w  ww  . j  a va  2 s . co m
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
   static void Main(string[] args)
   {
      // Variable of DateTime type, at first empty
      DateTime today;
      // Storing of today's date (without time component)
      today = DateTime.Today;
      // Output
      Console.WriteLine("Today is " + today);
   }
}

Result


Related Tutorials