What is the string format options for year in DateTime with C#

1 Answer

0 votes
using System;

public class Program
{
    public static void Main()
    {
        DateTime dt = new DateTime(2004, 03, 26);

        string s = String.Format("{0:y yy yyy yyyy}", dt);  
        
        Console.WriteLine(s);
    }
}




/*
run:

4 04 2004 2004

*/

 



answered Mar 26, 2022 by avibootz

Related questions

1 answer 161 views
1 answer 190 views
1 answer 170 views
1 answer 206 views
1 answer 164 views
1 answer 176 views
...