Does anyone know an easy way to format a time string in a 24 hour clock
setting (no AM/PM) in classic ASP ?
i.e.
HH:MM:SS

vbscript/asp doesn't support the Format statement, and FormatDateTime(Now(),
vbShortTime) will only give HH:MM

I really don't want to have to create vb dll just for this....

Thanks,
Mike

Re: format time as 24 hour time by Ray

Ray
Wed Jun 07 09:02:38 CDT 2006

Dim t
t = #1/1/2006 02:18:35 PM#
Response.Write p(Hour(t)) & ":" & p(Minute(t)) & ":" & p(Second(t))

Function p(i)
p = Right("00" & CStr(i), 2)
End Function


The "p" function is just meant to pad single digits with zeros, so that if
it's 1:05 PM, you get that 0 in front of the 5 when building the string.
Rename the function to something of your choice, or just eliminate it and
pad inline.

Ray at work





"Mike" <mberger@skypoint.com> wrote in message
news:kJWdnZqjufGFSBvZRVnysQ@skypoint.com...
> Does anyone know an easy way to format a time string in a 24 hour clock
> setting (no AM/PM) in classic ASP ?
> i.e.
> HH:MM:SS
>
> vbscript/asp doesn't support the Format statement, and
> FormatDateTime(Now(), vbShortTime) will only give HH:MM
>
> I really don't want to have to create vb dll just for this....
>
> Thanks,
> Mike
>



Re: format time as 24 hour time by Dr

Dr
Wed Jun 07 17:00:22 CDT 2006

JRS: In article <ebYnKsjiGHA.5088@TK2MSFTNGP02.phx.gbl>, dated Wed, 7
Jun 2006 10:02:38 remote, seen in news:microsoft.public.scripting.vbscri
pt, Ray Costanzo [MVP] <my@first.name> posted :
>Dim t
>t = #1/1/2006 02:18:35 PM#
>Response.Write p(Hour(t)) & ":" & p(Minute(t)) & ":" & p(Second(t))
>
>Function p(i)
> p = Right("00" & CStr(i), 2)
>End Function
>
>
>The "p" function is just meant to pad single digits with zeros, so that if
>it's 1:05 PM, you get that 0 in front of the 5 when building the string.
>Rename the function to something of your choice, or just eliminate it and
>pad inline.

ISTM that an explicit CStr is not needed, that only "0" need be
concatenated, and that Right(100+i, 2) may be faster.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.

Re: format time as 24 hour time by Ray

Ray
Thu Jun 08 08:25:50 CDT 2006


"Dr John Stockton" <jrs@merlyn.demon.co.uk> wrote in message
news:otGm3nC2x0hEFwFn@merlyn.demon.co.uk...

>>
>>Function p(i)
>> p = Right("00" & CStr(i), 2)
>>End Function
>>

> ISTM that an explicit CStr is not needed, that only "0" need be
> concatenated, and that Right(100+i, 2) may be faster.

True, CStr is rarely needed in the VBS world, but I guess I just do it out
of habit when I know that the variable is numeric.

Ray at work