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

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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
 
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 ; ...)
 
Rich said:
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"))
///
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top