|
| |
GMT
Ever got caught out by British Summer Time, or your own local time zone's
vagaries? This code allows you to use Greenwich Meantime so you will always be
sure what the time is at Greenwich!
Copy this code into a VBA module.
Option Explicit
Private Declare Sub GetSystemTime Lib "kernel32" (LPSYSTEMTIME As SYSTEMTIME)
Public Type SYSTEMTIME
WYEAR As Integer
WMONTH As Integer
WDAYOFWEEK As Integer
WDAY As Integer
WHOUR As Integer
WMINUTE As Integer
WSECOND As Integer
WMILLISECONDS As Integer
End Type
Public Function GETGMTDATE() As String
Application.Volatile
Dim ST As SYSTEMTIME
Dim DATESTRING As Single
GetSystemTime ST
DATESTRING = DateSerial(ST.WYEAR, ST.WMONTH, ST.WDAY)
GETGMTDATE = Format(DATESTRING, "DD MMM YYYY")
End Function
Public Function GETGMTTIME() As String
Application.Volatile
Dim ST As SYSTEMTIME
Dim TIMESTRING As Single
GetSystemTime ST
TIMESTRING = TimeSerial(ST.WHOUR, ST.WMINUTE, ST.WSECOND)
GETGMTTIME = Format(TIMESTRING, "HH:MM:SS")
End Function
|
Published: 16-Jul-2005
Last edited:
09-Mar-2011 19:39 |