Click here to Skip to main content
15,885,109 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friend
i am using
Dim datee As String = DateAndTime.Now
but in show me in 8/12/2012 6:38:13 AM
i want in 24 hour format
Posted

Just read the documentation:
http://msdn.microsoft.com/en-us/library/zdtaw1bw.aspx[^]

It will open your eyes :)
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 15-Aug-12 18:07pm    
Right, my 5 for eye opening, but I have an addition to this answer, for completeness, please see my solution.
--SA
C#
var dt = DateTime.Now;
Console.WriteLine(dt.ToString("MM/dd/yyyy HH:mm"));
 
Share this answer
 
Comments
Kenneth Haugland 15-Aug-12 15:38pm    
The same only different :) a5
Sergey Alexandrovich Kryukov 15-Aug-12 18:08pm    
Agree, my 5. I have an addition to Solution 1 and this one, for completeness; please see my solution.
--SA
RaviRanjanKr 18-Aug-12 1:36am    
My 5+
In addition to Solutions 1 and 2, pay attention for two different methods, where the format depends on particular culture:
http://msdn.microsoft.com/en-us/library/ht77y576.aspx[^],
http://msdn.microsoft.com/en-us/library/8tfzyc64.aspx[^].

Please also see:
http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo.aspx[^],
http://msdn.microsoft.com/en-us/library/system.iformatprovider.aspx[^].

As System.Globalization.CultureInfo implements System.IFormatProvider, you can use its instance as a parameter (please see the code sample in second link). Some cultures may already provide the format you need.

—SA
 
Share this answer
 
v2
HH - hours on 24-hour scale.

VB
Dim datee As String = Format(Now, "MM/dd/yyyy HH:ss")
 
Share this answer
 
v2
Comments
RaviRanjanKr 18-Aug-12 1:37am    
Always wrap your code in Pre tag even code is in Single Line.

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