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 Computer Name

C# Finding Tangent of an Angle

C# Finding the Desktop Path

C# Non-Restart Check If Application is Open

How to Find the Name of the Operating System in C# ?