Like somuch.com on Facebook Share somuch.com on Facebook somuch.com on Twitter Reddit LinkedIn Pinterest
Newest Tips & Tricks...

Home :: Tips & Tricks :: Active Server Pages

Time Function

This function gets rid of seconds, adds AM/PM in a time value. You may have to make changes depending on your server time format and region.


Function FixTime()
Dim TimeArray, CurrHour, CurrMin, AMPM

''Server is in Phoenix, I'm in EST so add 2 hours
TimeArray = DateAdd("h", 2, Time())

''Get AM/PM from time value
AMPM = " " & Right(TimeArray, 2)

TimeArray = Split(TimeArray, ":")
CurrHour = TimeArray(0)
CurrMin = TimeArray(1)

FixTime = CurrHour & ":" & CurrMin & AMPM

''Add timezone
FixTime = Trim(Right(FixTime, 8)) & " EST"

End Function

Source: Chuck Dearbeck

Recommended Links...