|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
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
|