...

View Full Version : DoDateTime Help



mattboy_slim
10-10-2003, 10:38 PM
I'm looking to get my Time format to display as:

8:00 AM or 5:30 PM

Right now, the closest I can get is:

08:30 or 17:30

What kind of a code do I need to get it into the preferred format?

Thanks,
Matt

glenngv
10-11-2003, 12:43 PM
Function convertTime(ByVal t)
dim hh, mm, ampm
if (not isdate(t)) then exit function
hh = hour(t)
mm = minute(t)
ampm = " AM"
if hh>=12 then ampm=" PM"
if hh>12 then
hh = hh - 12
elseif hh=0 then
hh=12
end if
if mm<10 then mm="0"&mm
convertTime = hh & ":" & mm & ampm
End Function

response.write "current time: " & convertTime(time()) & "<br>"
response.write "midnight: " & convertTime("00:00") & "<br>"
response.write "noon: " & convertTime("12:00") & "<br>"

whammy
10-13-2003, 03:10 AM
That reminds me of JavaScript date manipulation for some reason. ;)

But it should definitely work! Glenn's code is very reliable. :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum