How to format date to short and long date pattern in C#

1 Answer

0 votes
using System;
  
public class Program
{
    public static void Main()
    {
        DateTime dt = new DateTime(2004, 03, 06, 17, 30, 07, 235);
        
        string s = String.Format("{0:d}", dt);  
        Console.WriteLine(s);
        
        s = String.Format("{0:D}", dt);          
        Console.WriteLine(s);
    }
}
  
  
  
  
/*
run:
  
3/6/2004
Saturday, March 6, 2004
  
*/

 



answered Mar 27, 2022 by avibootz

Related questions

1 answer 114 views
1 answer 111 views
1 answer 133 views
1 answer 115 views
1 answer 127 views
1 answer 101 views
...