Attribute VB_Name = "unixtime" Option Explicit '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Copyright ©1996-2011 VBnet/Randy Birch, All Rights Reserved. ' Some pages may also contain other copyrights by the author. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ' Distribution: You can freely use this code in your own ' applications, but you may not reproduce ' or publish this code on any web site, ' online service, or distribute as source ' on any media without express permission. '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' Private Const TIME_ZONE_ID_UNKNOWN As Long = 1 Private Const TIME_ZONE_ID_STANDARD As Long = 1 Private Const TIME_ZONE_ID_DAYLIGHT As Long = 2 Private Const TIME_ZONE_ID_INVALID As Long = &HFFFFFFFF Private 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 Private Type TIME_ZONE_INFORMATION Bias As Long StandardName(0 To 63) As Byte 'unicode (0-based) StandardDate As SYSTEMTIME StandardBias As Long DaylightName(0 To 63) As Byte 'unicode (0-based) DaylightDate As SYSTEMTIME DaylightBias As Long End Type Private Declare Function GetTimeZoneInformation Lib "kernel32" _ (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long Function GetCurrentGMTfrom1970() As Long Dim tzi As TIME_ZONE_INFORMATION Dim gmt As Date Dim dwBias As Long Select Case GetTimeZoneInformation(tzi) Case TIME_ZONE_ID_DAYLIGHT dwBias = tzi.Bias + tzi.DaylightBias Case Else dwBias = tzi.Bias + tzi.StandardBias End Select gmt = DateAdd("n", dwBias, Now) GetCurrentGMTfrom1970 = DateDiff("s", "01/1/1970 12:00:00 AM", gmt) End Function