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 Path to the Windows AppData Folder

Splitting a String By Desired Character in C#

C# Finding Tangent of an Angle

Finding Character Count of String in C#

C# Taking Action by MessageBox OK Button