Click here to Skip to main content
15,891,689 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a label in my page and have set like this
Label1.Text=DateTime.Now.ToString("T"); it's is showing time in hours and minutes as per 12 hours format.
But I want in 24 hours format.

means 2:14 pm should be 14:14 .Please let me know how to do it?

Thanking you
mohd.wasif


Edit - Marked solved as commented by OP. - Ankur
Posted
Updated 6-Apr-11 2:05am
v2
Comments
Mohd Wasif 6-Apr-11 7:40am    
Solved

Try this,
DateTime.Now.ToString("HH:mm")
 
Share this answer
 
v2
hi,
try this one..

C#
static void Main()
{
   DateTime dateTime = DateTime.Now;
   C.WriteLine ("d = {0:d}", dateTime );  
   C.WriteLine ("D = {0:D}", dateTime ); 
   C.WriteLine ("f = {0:f}", dateTime );  
   C.WriteLine ("F = {0:F}", dateTime ); 
   C.WriteLine ("g = {0:g}", dateTime ); 
   C.WriteLine ("G = {0:G}", dateTime ); 
   C.WriteLine ("M = {0:M}", dateTime ); 
   C.WriteLine ("R = {0:R}", dateTime ); 
   C.WriteLine ("s = {0:s}", dateTime );  
   C.WriteLine ("t = {0:t}", dateTime );  
   C.WriteLine ("T = {0:T}", dateTime ); 
 
  C.WriteLine ("u = {0:u}", dateTime );  
 
  C.WriteLine ("U = {0:U}", dateTime );
 
  C.WriteLine ("Y = {0:Y}", dateTime );  
   C.WriteLine ("Month = " + dateTime.Month); 
 
   C.WriteLine ("Day Of Week = " + dateTime.DayOfWeek);     
 
   C.WriteLine ("Time Of Day = " + dateTime.TimeOfDay);     

   C.WriteLine("DateTime.Ticks = " + dateTime.Ticks);   
  
   }
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900