DataFormatString Military Time

Discussion in 'ASP .Net' started by Phillip Vong, Dec 19, 2006.

  1. Phillip Vong

    Phillip Vong Guest

    Simple question from a newbie. Using VWD in VB.NET for ASP.NET.

    I want to format a time value to show in military time only and without the
    seconds. I know it's not {0:t} or {0:T} but I can not figure out what it is.
    If it's 3:25 PM, I want it to show 15:25 only and without the seconds. This
    is what I found, but it did not provide me with the Military formating.

    http://datawebcontrols.com/faqs/CustomizingAppearance/FormatDateTimeData.shtml

    Thanks!

    Phil
     
    Phillip Vong, Dec 19, 2006
    #1
    1. Advertising

  2. Hi,
    You can try following two options:
    [1]{"H:mm"}
    Use uppercase H to display times based on the 24-hour clock (military
    clock). Uppercase H displays single-digit hours as single-digit numbers,
    without a leading zero.

    [2]{"HH:mm"}
    Use uppercase HH to display times based on the 24-hour clock (military
    clock). Uppercase HH displays single-digit hours with a leading zero.

    Thanks and Regards,
    Manish Bafna.
    MCP and MCTS.

    "Phillip Vong" wrote:

    > Simple question from a newbie. Using VWD in VB.NET for ASP.NET.
    >
    > I want to format a time value to show in military time only and without the
    > seconds. I know it's not {0:t} or {0:T} but I can not figure out what it is.
    > If it's 3:25 PM, I want it to show 15:25 only and without the seconds. This
    > is what I found, but it did not provide me with the Military formating.
    >
    > http://datawebcontrols.com/faqs/CustomizingAppearance/FormatDateTimeData.shtml
    >
    > Thanks!
    >
    > Phil
    >
    >
    >
     
    =?Utf-8?B?TWFuaXNoIEJhZm5h?=, Dec 19, 2006
    #2
    1. Advertising

  3. Phillip Vong

    Phillip Vong Guest

    Manish,
    Thanks!!!!
    In VWD, {H:mm} didn't work. I changed it to {0:H:mm} and it worked just
    fine!

    Thanks alot!!!
    Phil

    "Manish Bafna" <> wrote in message
    news:...
    > Hi,
    > You can try following two options:
    > [1]{"H:mm"}
    > Use uppercase H to display times based on the 24-hour clock (military
    > clock). Uppercase H displays single-digit hours as single-digit numbers,
    > without a leading zero.
    >
    > [2]{"HH:mm"}
    > Use uppercase HH to display times based on the 24-hour clock (military
    > clock). Uppercase HH displays single-digit hours with a leading zero.
    >
    > Thanks and Regards,
    > Manish Bafna.
    > MCP and MCTS.
    >
    > "Phillip Vong" wrote:
    >
    >> Simple question from a newbie. Using VWD in VB.NET for ASP.NET.
    >>
    >> I want to format a time value to show in military time only and without
    >> the
    >> seconds. I know it's not {0:t} or {0:T} but I can not figure out what it
    >> is.
    >> If it's 3:25 PM, I want it to show 15:25 only and without the seconds.
    >> This
    >> is what I found, but it did not provide me with the Military formating.
    >>
    >> http://datawebcontrols.com/faqs/CustomizingAppearance/FormatDateTimeData.shtml
    >>
    >> Thanks!
    >>
    >> Phil
    >>
    >>
    >>
     
    Phillip Vong, Dec 19, 2006
    #3
  4. Phillip Vong

    Mark Rae Guest

    "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
    news:...

    > In VWD, {H:mm} didn't work. I changed it to {0:H:mm} and it worked just
    > fine!


    Just in case you're intending to use this in databound controls (GridView
    etc) using the DataFormatString tag, you will also need to set the
    HtmlEncode tag to false or it won't work...
     
    Mark Rae, Dec 19, 2006
    #4
  5. Phillip Vong

    Phillip Vong Guest

    Mark, I did exactly that.

    Can someone help me format this so it's in H:mm format? I'm using this with
    a button On_Click and I'm not sure what the formatting command is.
    Thanks!

    Dim CurTime As DateTime = DateTime.Now

    TextBox1.Text = CurTime




    "Mark Rae" <> wrote in message
    news:uH$...
    > "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
    > news:...
    >
    >> In VWD, {H:mm} didn't work. I changed it to {0:H:mm} and it worked just
    >> fine!

    >
    > Just in case you're intending to use this in databound controls (GridView
    > etc) using the DataFormatString tag, you will also need to set the
    > HtmlEncode tag to false or it won't work...
    >
     
    Phillip Vong, Dec 19, 2006
    #5
  6. Phillip Vong

    Mark Rae Guest

    "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
    news:...

    > Can someone help me format this so it's in H:mm format?


    Dim CurTime As DateTime = DateTime.Now.ToString("H:mm")

    TextBox1.Text = CurTime
     
    Mark Rae, Dec 19, 2006
    #6
  7. Phillip Vong

    Phillip Vong Guest

    When I try that, I get non military time like 3:31:00 PM.

    Dim CurTime As DateTime = DateTime.Now.ToString("H:mm")

    TextBox1.Text = CurTime



    "Mark Rae" <> wrote in message
    news:%23%...
    > "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
    > news:...
    >
    >> Can someone help me format this so it's in H:mm format?

    >
    > Dim CurTime As DateTime = DateTime.Now.ToString("H:mm")
    >
    > TextBox1.Text = CurTime
    >
     
    Phillip Vong, Dec 19, 2006
    #7
  8. Phillip Vong

    Mark Rae Guest

    Mark Rae, Dec 19, 2006
    #8
  9. Phillip Vong

    Phillip Vong Guest

    Anyone?


    "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
    news:...
    > When I try that, I get non military time like 3:31:00 PM.
    >
    > Dim CurTime As DateTime = DateTime.Now.ToString("H:mm")
    >
    > TextBox1.Text = CurTime
    >
    >
    >
    > "Mark Rae" <> wrote in message
    > news:%23%...
    >> "Phillip Vong" <phillip_vong*at*yahoo*dot*com> wrote in message
    >> news:...
    >>
    >>> Can someone help me format this so it's in H:mm format?

    >>
    >> Dim CurTime As DateTime = DateTime.Now.ToString("H:mm")
    >>
    >> TextBox1.Text = CurTime
    >>

    >
    >
     
    Phillip Vong, Dec 21, 2006
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. P. Flavin
    Replies:
    1
    Views:
    6,061
    P. Flavin
    Sep 12, 2003
  2. flamesrock
    Replies:
    8
    Views:
    552
    Hendrik van Rooyen
    Nov 24, 2006
  3. Replies:
    1
    Views:
    1,447
    Roedy Green
    Sep 22, 2007
  4. David Hearn
    Replies:
    1
    Views:
    443
    David Hearn
    Sep 10, 2003
  5. Scott

    Military Time Problem

    Scott, Jan 25, 2006, in forum: ASP General
    Replies:
    4
    Views:
    308
    Scott
    Jan 27, 2006
Loading...

Share This Page