Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > DataFormatString Military Time

Reply
Thread Tools

DataFormatString Military Time

 
 
Phillip Vong
Guest
Posts: n/a
 
      12-19-2006
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/Cust...TimeData.shtml

Thanks!

Phil


 
Reply With Quote
 
 
 
 
=?Utf-8?B?TWFuaXNoIEJhZm5h?=
Guest
Posts: n/a
 
      12-19-2006
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/Cust...TimeData.shtml
>
> Thanks!
>
> Phil
>
>
>

 
Reply With Quote
 
 
 
 
Phillip Vong
Guest
Posts: n/a
 
      12-19-2006
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:9D9B0348-3DB7-45EE-9EA9-...
> 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/Cust...TimeData.shtml
>>
>> Thanks!
>>
>> Phil
>>
>>
>>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      12-19-2006
"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...


 
Reply With Quote
 
Phillip Vong
Guest
Posts: n/a
 
      12-19-2006
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...
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      12-19-2006
"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


 
Reply With Quote
 
Phillip Vong
Guest
Posts: n/a
 
      12-19-2006
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
>



 
Reply With Quote
 
Mark Rae
Guest
Posts: n/a
 
      12-19-2006
"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.


Hmm - OK, that's a little strange. That's definitely the correct way to do
it, though:
http://msdn2.microsoft.com/en-us/lib...d4(VS.80).aspx


 
Reply With Quote
 
Phillip Vong
Guest
Posts: n/a
 
      12-21-2006
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
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
military time in java mrshinton01@gmail.com Java 1 09-22-2007 02:11 AM
Military Time Problem Scott ASP General 4 01-27-2006 11:53 PM
OE shows military time Robin Computer Support 10 10-26-2004 04:42 PM
Does Military Prepare for IT career? Frederick MCSE 24 12-02-2003 10:05 PM
Formatting a time field to 24 hour time (Military time) in the Datagrid David Hearn ASP .Net Datagrid Control 1 09-10-2003 02:50 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57