Soren Winslow 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 : 12/28/2024 2:59:43 PM
HoursTimeDateAdd() FormulaDecimal Formula
-2312/27/2024 3:59:43 PMDateAdd("h",-23,Now())Now()-0.95833
-2212/27/2024 4:59:43 PMDateAdd("h",-22,Now())Now()-0.91667
-2112/27/2024 5:59:43 PMDateAdd("h",-21,Now())Now()-0.87500
-2012/27/2024 6:59:43 PMDateAdd("h",-20,Now())Now()-0.83333
-1912/27/2024 7:59:43 PMDateAdd("h",-19,Now())Now()-0.79167
-1812/27/2024 8:59:43 PMDateAdd("h",-18,Now())Now()-0.75000
-1712/27/2024 9:59:43 PMDateAdd("h",-17,Now())Now()-0.70833
-1612/27/2024 10:59:43 PMDateAdd("h",-16,Now())Now()-0.66667
-1512/27/2024 11:59:43 PMDateAdd("h",-15,Now())Now()-0.62500
-1412/28/2024 12:59:43 AMDateAdd("h",-14,Now())Now()-0.58333
-1312/28/2024 1:59:43 AMDateAdd("h",-13,Now())Now()-0.54167
-1212/28/2024 2:59:43 AMDateAdd("h",-12,Now())Now()-0.50000
-1112/28/2024 3:59:43 AMDateAdd("h",-11,Now())Now()-0.45833
-1012/28/2024 4:59:43 AMDateAdd("h",-10,Now())Now()-0.41667
-912/28/2024 5:59:43 AMDateAdd("h",-9,Now())Now()-0.37500
-812/28/2024 6:59:43 AMDateAdd("h",-8,Now())Now()-0.33333
-712/28/2024 7:59:43 AMDateAdd("h",-7,Now())Now()-0.29167
-612/28/2024 8:59:43 AMDateAdd("h",-6,Now())Now()-0.25000
-512/28/2024 9:59:43 AMDateAdd("h",-5,Now())Now()-0.20833
-412/28/2024 10:59:43 AMDateAdd("h",-4,Now())Now()-0.16667
-312/28/2024 11:59:43 AMDateAdd("h",-3,Now())Now()-0.12500
-212/28/2024 12:59:43 PMDateAdd("h",-2,Now())Now()-0.08333
-112/28/2024 1:59:43 PMDateAdd("h",-1,Now())Now()-0.04167
012/28/2024 2:59:43 PMNow()
-112/28/2024 3:59:43 PMDateAdd("h",1,Now())Now()+0.04167
-212/28/2024 4:59:43 PMDateAdd("h",2,Now())Now()+0.08333
-312/28/2024 5:59:43 PMDateAdd("h",3,Now())Now()+0.12500
-412/28/2024 6:59:43 PMDateAdd("h",4,Now())Now()+0.16667
-512/28/2024 7:59:43 PMDateAdd("h",5,Now())Now()+0.20833
-612/28/2024 8:59:43 PMDateAdd("h",6,Now())Now()+0.25000
-712/28/2024 9:59:43 PMDateAdd("h",7,Now())Now()+0.29167
-812/28/2024 10:59:43 PMDateAdd("h",8,Now())Now()+0.33333
-912/28/2024 11:59:43 PMDateAdd("h",9,Now())Now()+0.37500
-1012/29/2024 12:59:43 AMDateAdd("h",10,Now())Now()+0.41667
-1112/29/2024 1:59:43 AMDateAdd("h",11,Now())Now()+0.45833
-1212/29/2024 2:59:43 AMDateAdd("h",12,Now())Now()+0.50000
-1312/29/2024 3:59:43 AMDateAdd("h",13,Now())Now()+0.54167
-1412/29/2024 4:59:43 AMDateAdd("h",14,Now())Now()+0.58333
-1512/29/2024 5:59:43 AMDateAdd("h",15,Now())Now()+0.62500
-1612/29/2024 6:59:43 AMDateAdd("h",16,Now())Now()+0.66667
-1712/29/2024 7:59:43 AMDateAdd("h",17,Now())Now()+0.70833
-1812/29/2024 8:59:43 AMDateAdd("h",18,Now())Now()+0.75000
-1912/29/2024 9:59:43 AMDateAdd("h",19,Now())Now()+0.79167
-2012/29/2024 10:59:43 AMDateAdd("h",20,Now())Now()+0.83333
-2112/29/2024 11:59:43 AMDateAdd("h",21,Now())Now()+0.87500
-2212/29/2024 12:59:43 PMDateAdd("h",22,Now())Now()+0.91667
-2312/29/2024 1:59:43 PMDateAdd("h",23,Now())Now()+0.95833
© 1967 - 2024 Soren Winslow