C# Getting Today's Date

In C# there are different methods to fetch today's date. Let's examine the examples below..

namespace ConsoleApplicationTest
{
    class Program {

        static void Main(string[] args) {
        
            DateTime t1 = System.DateTime.Today;
            string t2 = DateTime.Today.ToString("d/MM/yyyy");
            string t3 = DateTime.Now.ToString("d/MM/yyyy");
            string t4 = DateTime.Now.Date.ToShortDateString();

            Console.WriteLine(t1);
            Console.WriteLine(t2);
            Console.WriteLine(t3);
            Console.WriteLine(t4);

            Console.ReadLine();
        }
    }
}



You May Interest

C# Finding the Desktop Path

C# Finding the Sine of an Angle

Splitting a String By Desired Character in C#

C# Substring Method

C# Finding the Path to the Windows AppData Folder