Get "now" and the day of week now. - CSharp Language Basics

CSharp examples for Language Basics:Date Time

Description

Get "now" and the day of week now.

Demo Code

using System;//from  w  w w . j  a v a 2 s  . c om
class Program
{
   static void Main(string[] args)
   {
      //
      DateTime thisMoment = DateTime.Now;
      DayOfWeek dayOfWeek = DateTime.Now.DayOfWeek;
      Console.WriteLine("Today (right now) is {0}, {1}", dayOfWeek, thisMoment); // e.g. "Sunday, 7/15/2007 2:24:37 PM".
      Console.WriteLine("This year is {0}", thisMoment.Year);
   }
}

Result


Related Tutorials