Facebook Twitter Reddit LinkedIn

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
© 2007-2019 All rights reserved.   Part of the somuch.com group of trusted web sites.   PO Box 351031, Palm Coast FL 32135-1031