How do you know if it's daylight savings?

how can you get the time zone information on whether or not the system is using daylight savings or not using visual basic?

Thanks
thydAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
Erick37Connect With a Mentor Commented:
Using API:
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'See the Timezone.zip example at
'http://www.mvps.org/vb/index2.html?samples.htm
Option Explicit
Private Const TIME_ZONE_ID_INVALID = (-1)
Private Const TIME_ZONE_ID_UNKNOWN = 0
Private Const TIME_ZONE_ID_STANDARD = 1
Private Const TIME_ZONE_ID_DAYLIGHT = 2

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(32) As Integer
    StandardDate As SYSTEMTIME
    StandardBias As Long
    DaylightName(32) As Integer
    DaylightDate As SYSTEMTIME
    DaylightBias As Long
End Type
Private Declare Function GetTimeZoneInformation Lib "kernel32" _
    (lpTimeZoneInformation As TIME_ZONE_INFORMATION) As Long

Private Sub Command1_Click()
    Dim lRet As Long
    Dim tzi As TIME_ZONE_INFORMATION
    lRet = GetTimeZoneInformation(tzi)
    Select Case lRet
    Case TIME_ZONE_ID_DAYLIGHT
        Debug.Print "Daylight Savings Time"
    Case TIME_ZONE_ID_STANDARD
        Debug.Print "Standard Time"
    Case TIME_ZONE_ID_UNKNOWN
        Debug.Print "Unknown Timezone"
    Case Else
        Debug.Print "GetTimeZone Failed"
    End Select
End Sub
0
 
thydAuthor Commented:
Edited text of question.
0
 
thydAuthor Commented:
Thank-you very much!


Thy
0
 
Erick37Commented:
You're welcome :-)
0
All Courses

From novice to tech pro — start learning today.