Reputation: 114
I know this probably is considered a repeat question so I will apologize in advance, but I have looked at question after question and everyone says the "hh" will display a 12 hour format. I keep getting a 24 hour format as if I have "HH". What gives?
strTime = Date.Now.ToString("hhmmsstt")
Upvotes: 2
Views: 208
Reputation: 320
You can try
strTime = Date.Now.ToLocalTime()
to get a local time.
Upvotes: 0
Reputation: 358
You can use it like this
strtime = Format(Now, "hh:mm tt")
You get an output like this
04:33 PM
If for something you dont want the 0 behind 4 you just take out one h
strtime = Format(Now, "h:mm tt")
Upvotes: 0
Reputation: 1086
On this link you can check all the possible time formats, so you are interested about the following:
"h"
The hour, using a 12-hour clock from 1 to 12.
More information: The "h" Custom Format Specifier.
"hh"
The hour, using a 12-hour clock from 01 to 12.
More information: The "hh" Custom Format Specifier.
"H"
The hour, using a 24-hour clock from 0 to 23.
More information: The "H" Custom Format Specifier.
"HH"
The hour, using a 24-hour clock from 00 to 23.
More information: The "HH" Custom Format Specifier.
Upvotes: 1