Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Display time in 24hours format?

Status
Not open for further replies.

Jacksparrow87

Technical User
Jun 29, 2008
93
GB
Hi

Newbie here just asking a few simple questions regarding displaying my date and time in 24hour clock format (As it currently displays it in the 12hour clock format.)

In my application I display the date and time in 2 different places, for the first part I have used a ticker and the following coding:

lbldate.Text = Date.Now.ToString("dd MMM yyyy hh:mm:ss")

On the 2nd part I have used a date/time picker and changed the format to custom and the customformat to dd/MM/yyyy hh:mm

The coding I have used for the datetime picker is as follows:

dtp.Value = Date.Now

Any help would be excellent, thanks.

*Those who dont understand the difference a 24hour clock format would display the time as 18:09 compared to a 12 hour clock format which would display it as 6:09*
 

Google on "VB.NET Military Time" gave me this:
Code:
lbldate.Text = Date.Now.ToString("dd MMM yyyy [b][red]HH[/red][/b]:mm:ss")
Just change small 'hh' to 'HH'

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top