473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DataFormatString Military Time

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
Dec 19 '06 #1
8 21748
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
Dec 19 '06 #2
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" <Ma*********@discussions.microsoft.comwrote in message
news:9D**********************************@microsof t.com...
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

Dec 19 '06 #3
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:e4**************@TK2MSFTNGP04.phx.gbl...
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...
Dec 19 '06 #4
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" <ma**@markNOSPAMrae.comwrote in message
news:uH**************@TK2MSFTNGP06.phx.gbl...
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:e4**************@TK2MSFTNGP04.phx.gbl...
>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...

Dec 19 '06 #5
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:us**************@TK2MSFTNGP02.phx.gbl...
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
Dec 19 '06 #6
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" <ma**@markNOSPAMrae.comwrote in message
news:%2******************@TK2MSFTNGP06.phx.gbl...
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:us**************@TK2MSFTNGP02.phx.gbl...
>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

Dec 19 '06 #7
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:uv**************@TK2MSFTNGP06.phx.gbl...
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
Dec 19 '06 #8
Anyone?
"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:uv**************@TK2MSFTNGP06.phx.gbl...
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" <ma**@markNOSPAMrae.comwrote in message
news:%2******************@TK2MSFTNGP06.phx.gbl...
>"Phillip Vong" <phillip_vong*at*yahoo*dot*comwrote in message
news:us**************@TK2MSFTNGP02.phx.gbl...
>>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


Dec 21 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Al | last post by:
Hi Is it a function to convert time to and from military time? Thanks
4
by: richardkreidl | last post by:
How would I check to see if the current time(military format) is greater then 07:30AM and the day of the week is Monday-Friday. Pseudo code: If Current_Time > 07:30AM and Current_Day = Monday...
5
by: Scott | last post by:
If I have a datetime sql field with afternoon datetime values like below in DATETIME VALUE, how can I display the time part in ASP as 1:00 PM, instead of 13:00 PM as seen in CURRENT RESULTS below?...
1
by: ApexData | last post by:
Hello Any know how to convert AM/PM Time to 24Hr Time ? Sample Please ! With and without Now(). ThankYou Greg
3
by: wocosc | last post by:
I have a quick question.. How can get python to take whatever time of day it is, and output it as military time? I already know how to get it to return the specific time.
8
AccessIdiot
by: AccessIdiot | last post by:
Argh! This is driving me crazy. My db users want to be able to enter a string of numbers for hours, minutes, seconds, in military time format (021256 for 2:12:56 a.m. and 152416 for 3:24:16 p.m.)....
1
by: okaymy1112 | last post by:
I have data in this format 0800, 1730, 0930, etc. I do not know how to convert this time to read something like, 8:00AM, 5:30 PM, 9:30AM etc. Also I want to group things by day. I have courses...
4
by: drg | last post by:
My assignment is actually encapsulation which is not the problem -- my program needs to take two military times and calculate the minutes elapsed between the two. I have everything worked out so...
1
by: mdthom08 | last post by:
I can't figure out the formula to convert military time all to minutes.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.