Link to home
Start Free TrialLog in
Avatar of kuney
kuney

asked on

VBS Convert Time hh:mm:ss (1:23:58 PM) to HH:mm:ss (13:23:58)

How do convert  a time hh:mm:ss (1:23:58 PM) to Military time HH:mm:ss (13:23:58) in vbscript
I know that FormatDateTime will do a 24-hour format using vbShortTime but I need to keep the seconds at the end.  Here is an example using vb function FormatDateTime

Dim Time
Dim FTime

FTime = FormatDateTime(Time, 4)

But this cuts of the seconds and I need the seconds

Please HELP!
Avatar of Patrick Matthews
Patrick Matthews
Flag of United States of America image

FTime = Right("0" & Hour(Time), 2) & ":" & Right("0" & Minute(Time), 2) & ":" & Right("0" & Minute(Time), 2)
ASKER CERTIFIED SOLUTION
Avatar of kuney
kuney

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
kuney,

Get rid of your variable Time; there is already a Time function that returns the current system time, shorn of
its date portion.  My code suggestion assumes you are using the Time function, and *not* your variable Time.

Regards,

Patrick