Formatting "Short Time" in VB.NET

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • rehughes

    Formatting "Short Time" in VB.NET

    When I use: Format(datetime , "Short Time") or Format(datetime , "t") or
    Format(datetime , "hh:mm") I always get an AM/PM value on the end of the time
    string. How do I get a short time in military format without AM/PM? Thanks.
    Bob Hughes


  • Cor Ligthert

    #2
    Re: Formatting "Short Time" in VB.NET

    ReHuges,

    This is only for the cultures where the PM and AM are used. This format is
    called in the US Military time.

    In those cultures you can use "HH:mm" in the others both hh:mm and HH:mm
    will work the same.

    I hope this helps?

    Cor


    Comment

    • Crouchie1998

      #3
      Re: Formatting "Short Time" in VB.NET

      Try these:

      Dim strTime As String = Format(DateTime .Now, "HH:mm")
      MessageBox.Show (strTime, "Time Example")

      Dim strTime As DateTime
      MessageBox.Show (strTime.Now.To ShortTimeString , "Time Example")

      I hope this helps

      Comment

      Working...