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

1 Answer

0 votes
using System;
 
public class Program
{
    public static void Main()
    {
        DateTime dt = new DateTime(2004, 03, 06, 14, 03, 31);
 
        string s = String.Format("{0:h hh H HH}", dt);  
         
        Console.WriteLine(s);
    }
}
 
 
 
 
/*
run:
 
2 02 14 14
 
*/

 



answered Mar 27, 2022 by avibootz

Related questions

1 answer 172 views
1 answer 190 views
1 answer 170 views
1 answer 206 views
1 answer 177 views
1 answer 180 views
...