CSharp - DateTime DateTimeOffset current value Now

Introduction

Both DateTime and DateTimeOffset have a static Now property that returns the current date and time:

DateTime also provides a Today property that returns just the date portion:

The static UtcNow property returns the current date and time in UTC:

Demo

using System;
class MainClass/*  w  w  w.  j a v a2 s .  c o  m*/
{
   public static void Main(string[] args)
   {
     Console.WriteLine (DateTime.Now);         
     Console.WriteLine (DateTimeOffset.Now);   
     Console.WriteLine (DateTime.Today);       
     Console.WriteLine (DateTime.UtcNow);      
     Console.WriteLine (DateTimeOffset.UtcNow);
   }
}

Result

Related Topic