DataFormatString Military Time

  • Thread starter Thread starter Phillip Vong
  • Start date Start date
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.
 
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 said:
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 said:
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
 
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, 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
 
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
 
Anyone?


Phillip Vong said:
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
 
Back
Top