Soren Winslow
Time Zone Adjustment Utility
If your server is in the Eastern time Zone and you are in the Pacific time zone, and you would like to get some accurate times without having to think as much. For example, you are keeping some kind of page hit log and you would like to see the time/date stamp in your time zone instead of the servers time zone. Here is a list of hourly fractions to add or subtract to the the function Now() to get a more accurate time.
There are two different ways that you can add or subtract hours to the current server time. You can simply use the VBScript DateAdd() function or you can also add the hourly decimal equivalent to the server time (shown as Now())
This script should also help you determine what timezone your server is in by counting the hour differences between Now() and yoru local time. If Now() is aproximately the same as the time on your computer then you are in the same timezone as your server.

Here is the ASP code for this script:

<%



  CurrentTime = Now()

  Response.Write "<b>Current Server Time : " & _

                 CurrentTime & _

                 "</b><br>"



  Response.Write "<table border=" & chr(34) & "1" & chr(34) & " " & _

                         "cellspacing=" & chr(34) & "0" & chr(34) & ">" & _

                 "<tr class=" & chr(34) & "breg" & chr(34) & " " & _

                      "style=" & chr(34) & "text-align:center;" & chr(34) & ">" & _

                 "<td><b>Hours</b></td>" & _

                 "<td><b>Time</b></td>" & _

                 "<td><b>DateAdd() Formula</b></td>" & _

                 "<td><b>Decimal Formula</b></td>" & _

                 "</tr>"



  For x = 23 to 1 step -1

     HourDecimal = FormatNumber(x/24,5)



     Response.Write "<tr class=" & chr(34) & "breg" & chr(34) & ">" & _

                    "<td>-" & x & "</td>" & _

                    "<td>" & DateAdd("h",x*-1,CurrentTime) & "</td>" & _

                    "<td>DateAdd(" & chr(34) & "h" & chr(34) & "," & x*-1 & ",Now())</td>" & _

                    "<td>Now()-" & HourDecimal & "</td>" & _

                    "</tr>"





  Next







   Response.Write "<tr class=" & chr(34) & "breg" & chr(34) & ">" & _

                  "<td><b>0</b></td>" & _

                  "<td><b>" & CurrentTime & "</b></td>" & _

                  "<td colspan=" & chr(34) & "2" & chr(34) & " " & _

                       "style=" & chr(34) & "text-align:center" & chr(34) & ">" & _

                       "<b>Now()</b>" & _

                  "</td>" & _

                  "</tr>"





  For x = 1 to 23

     HourDecimal = FormatNumber(x/24,5)



     Response.Write "<tr class=" & chr(34) & "breg" & chr(34) & ">" & _

                    "<td>-" & x & "</td>" & _

                    "<td>" & DateAdd("h",x,CurrentTime) & "</td>" & _

                    "<td>DateAdd(" & chr(34) & "h" & chr(34) & "," & x & ",Now())</td>" & _

                    "<td>Now()+" & HourDecimal & "</td>" & _

                    "</tr>"





  Next



  Response.Write "</table>"





  %>

               

Here is the running script:
Current Server Time : 11/27/2024 12:45:25 AM
HoursTimeDateAdd() FormulaDecimal Formula
-2311/26/2024 1:45:25 AMDateAdd("h",-23,Now())Now()-0.95833
-2211/26/2024 2:45:25 AMDateAdd("h",-22,Now())Now()-0.91667
-2111/26/2024 3:45:25 AMDateAdd("h",-21,Now())Now()-0.87500
-2011/26/2024 4:45:25 AMDateAdd("h",-20,Now())Now()-0.83333
-1911/26/2024 5:45:25 AMDateAdd("h",-19,Now())Now()-0.79167
-1811/26/2024 6:45:25 AMDateAdd("h",-18,Now())Now()-0.75000
-1711/26/2024 7:45:25 AMDateAdd("h",-17,Now())Now()-0.70833
-1611/26/2024 8:45:25 AMDateAdd("h",-16,Now())Now()-0.66667
-1511/26/2024 9:45:25 AMDateAdd("h",-15,Now())Now()-0.62500
-1411/26/2024 10:45:25 AMDateAdd("h",-14,Now())Now()-0.58333
-1311/26/2024 11:45:25 AMDateAdd("h",-13,Now())Now()-0.54167
-1211/26/2024 12:45:25 PMDateAdd("h",-12,Now())Now()-0.50000
-1111/26/2024 1:45:25 PMDateAdd("h",-11,Now())Now()-0.45833
-1011/26/2024 2:45:25 PMDateAdd("h",-10,Now())Now()-0.41667
-911/26/2024 3:45:25 PMDateAdd("h",-9,Now())Now()-0.37500
-811/26/2024 4:45:25 PMDateAdd("h",-8,Now())Now()-0.33333
-711/26/2024 5:45:25 PMDateAdd("h",-7,Now())Now()-0.29167
-611/26/2024 6:45:25 PMDateAdd("h",-6,Now())Now()-0.25000
-511/26/2024 7:45:25 PMDateAdd("h",-5,Now())Now()-0.20833
-411/26/2024 8:45:25 PMDateAdd("h",-4,Now())Now()-0.16667
-311/26/2024 9:45:25 PMDateAdd("h",-3,Now())Now()-0.12500
-211/26/2024 10:45:25 PMDateAdd("h",-2,Now())Now()-0.08333
-111/26/2024 11:45:25 PMDateAdd("h",-1,Now())Now()-0.04167
011/27/2024 12:45:25 AMNow()
-111/27/2024 1:45:25 AMDateAdd("h",1,Now())Now()+0.04167
-211/27/2024 2:45:25 AMDateAdd("h",2,Now())Now()+0.08333
-311/27/2024 3:45:25 AMDateAdd("h",3,Now())Now()+0.12500
-411/27/2024 4:45:25 AMDateAdd("h",4,Now())Now()+0.16667
-511/27/2024 5:45:25 AMDateAdd("h",5,Now())Now()+0.20833
-611/27/2024 6:45:25 AMDateAdd("h",6,Now())Now()+0.25000
-711/27/2024 7:45:25 AMDateAdd("h",7,Now())Now()+0.29167
-811/27/2024 8:45:25 AMDateAdd("h",8,Now())Now()+0.33333
-911/27/2024 9:45:25 AMDateAdd("h",9,Now())Now()+0.37500
-1011/27/2024 10:45:25 AMDateAdd("h",10,Now())Now()+0.41667
-1111/27/2024 11:45:25 AMDateAdd("h",11,Now())Now()+0.45833
-1211/27/2024 12:45:25 PMDateAdd("h",12,Now())Now()+0.50000
-1311/27/2024 1:45:25 PMDateAdd("h",13,Now())Now()+0.54167
-1411/27/2024 2:45:25 PMDateAdd("h",14,Now())Now()+0.58333
-1511/27/2024 3:45:25 PMDateAdd("h",15,Now())Now()+0.62500
-1611/27/2024 4:45:25 PMDateAdd("h",16,Now())Now()+0.66667
-1711/27/2024 5:45:25 PMDateAdd("h",17,Now())Now()+0.70833
-1811/27/2024 6:45:25 PMDateAdd("h",18,Now())Now()+0.75000
-1911/27/2024 7:45:25 PMDateAdd("h",19,Now())Now()+0.79167
-2011/27/2024 8:45:25 PMDateAdd("h",20,Now())Now()+0.83333
-2111/27/2024 9:45:25 PMDateAdd("h",21,Now())Now()+0.87500
-2211/27/2024 10:45:25 PMDateAdd("h",22,Now())Now()+0.91667
-2311/27/2024 11:45:25 PMDateAdd("h",23,Now())Now()+0.95833
© 1967 - 2024 Soren Winslow