Translate

Using DateTime in C#

Below is very simple usage of DateTime -

class DateTimePr
    {
        static void Main(string[] args)
        {
            var datetime = new DateTime();
            var now = DateTime.Now;
            var today = DateTime.Today;
 
            Console.WriteLine(now);
            Console.WriteLine(today);
 
            Console.WriteLine(now.Hour);
            Console.WriteLine(now.ToLongDateString());
            Console.WriteLine(now.ToString());
        }
    }