Soren Winslow
Standard or Daylight Savings Time Period Function
This is a function that will automatically (based on U.S. time changes) will determine if your date/time is during the standard time period or during the daylight saving time period. An example of this may be if you are pulling data out of a database to create an RSS file where the time zone must be specified to conform (and be valid) to the RSS 2.0 Specifications.
This function is based on the new time change schedule in the United States of changing to Daylight Saving Time at 2:00 AM on second Sunday in March and changing back to Standard Time on first Sunday in November at 2:00 AM.
The function shown here, represents the Pacific Time Zone. So you will need to change the abreviations accordingly. Here is a list of U.S. time zone abbreviations:
Time Zone Standard Time Saving Time
Alaska AKST AKDT
Pacific PST PDT
Mountian MST MDT
Central CST CDT
Eastern EST EDT
Hawaii is not listed above, because Hawaii does not observe Daylight Saving Time.
Here is an example of how to use it.
<%
Response.Write StDst(Now())
%>
The output is 10/20/2017 12:12:10 AM PDT

Here is the ASP code for the StDst() function:



 Function StDst(TheDate)

    TheDate = CDate(TheDate)

    DstStart = CDate("03/08/" & Year(Date()) & " 02:00")

    DstEnd = CDate("11/01/" & Year(Date()) & " 02:00")

    While Weekday(DstStart) <> 1

       DstStart = DstStart + 1

    Wend

    While Weekday(DstEnd) <> 1

       DstEnd = DstEnd + 1

    Wend

    If TheDate >= DstStart AND TheDate <= DstEnd Then

       StDst = TheDate & " PDT"

    Else

       StDst = TheDate & " PST"

    End If

 End Function



               
© 1967 - 2017 Soren Winslow