469,943 Members | 2,594 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,943 developers. It's quick & easy.

how to get HH:mm:ss format of Now.ToShortTimeString?

Now.ToShortTimeString returns 9:13 PM.

I would like to get this in miliatry time with seconds included 21:13:45
(or something like that - just military time with seconds). How can this be
done?

Thanks,
Rich
Nov 21 '05 #1
4 38034
Capitilize the hours:

Dim dtTime As String = Format(DateTime.Now, "HH:mm:ss")
MessageBox.Show(dtTime)

I hope this helps,

Crouchie1998
BA (HONS) MCP MCSE
Nov 21 '05 #2
Thanks for your replie. Actually, I was using that, but just checking if
there was a different way where I did not have to precede Now... with Format.
Here is what I came up with that seems to do the trick

Now.ToString("HH:mm:ss")

It is a C# method, but C# and VB.Net are pretty much the same now except for
Dim and you have modules in VB (and no { } or ; ...)

"Crouchie1998" wrote:
Capitilize the hours:

Dim dtTime As String = Format(DateTime.Now, "HH:mm:ss")
MessageBox.Show(dtTime)

I hope this helps,

Crouchie1998
BA (HONS) MCP MCSE

Nov 21 '05 #3
"Rich" <Ri**@discussions.microsoft.com> schrieb:
Now.ToShortTimeString returns 9:13 PM.

I would like to get this in miliatry time with seconds included 21:13:45
(or something like that - just military time with seconds). How can this
be
done?


\\\
MsgBox(Now().ToString("HH:mm:ss"))
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #4
On Mon, 11 Jul 2005 10:11:04 -0700, Rich wrote:
Now.ToString("HH:mm:ss")

It is a C# method, but C# and VB.Net are pretty much the same now except for
Dim and you have modules in VB (and no { } or ; ...)


It's actually a standard method of the Datetime class, available for all
languages. Datetime is the return type of the Now() function.
Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

15 posts views Thread by Jay Tee | last post: by
1 post views Thread by Vishal Bhargava | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.