How to Convert Datetime to DD/MM/YYYY Format in C#/CSharp

Sample code is given below.  Make sure MM is in capital letters.

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
using System;
namespace Hello_World
{
class Program
{
static void Main(string[] args)
{
DateTime today = DateTime.Now;
string dt = today.ToString("dd/MM/yyyy");
Console.WriteLine(dt);
}
}
}
;
using System; namespace Hello_World { class Program { static void Main(string[] args) { DateTime today = DateTime.Now; string dt = today.ToString("dd/MM/yyyy"); Console.WriteLine(dt); } } } ;
using System;



namespace Hello_World
{

    class Program
    {
        static void Main(string[] args)
        {
            DateTime today = DateTime.Now;

            string dt = today.ToString("dd/MM/yyyy");

            Console.WriteLine(dt);
        }
    }
}
;