jerf26134
asked on
How to get GMT in ASP
I have a database that is used across the country within the company I work with. I have a search page the searches area codes and returns all matching area codes with the current time in that area code.
I would take the server time, but unfortunately, the site is located on a few servers to balance the load and some of the servers are not located in the same timezone as the others.
Is there anyway to have the server calculate GMT and use that as the basis of the time calculation, or do I have to get the local time from the client and then calculate it that way? I can't believe that there isnt anyway to do this from the server. Please help!
I would take the server time, but unfortunately, the site is located on a few servers to balance the load and some of the servers are not located in the same timezone as the others.
Is there anyway to have the server calculate GMT and use that as the basis of the time calculation, or do I have to get the local time from the client and then calculate it that way? I can't believe that there isnt anyway to do this from the server. Please help!
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Ok, I got it working with some tweaking. Here is the final answer I came to in case anyone is looking for it in the future:
time.asp --
<script language="jscript" runat="server">
d = new Date();
tz = -d.getTimezoneOffset()/60;
</script>
<%
gmtime = DateAdd("h",tz,now)
gmtime = FormatDateTime(gmtime, 3)
response.write gmtime
%>
time.asp --
<script language="jscript" runat="server">
d = new Date();
tz = -d.getTimezoneOffset()/60;
</script>
<%
gmtime = DateAdd("h",tz,now)
gmtime = FormatDateTime(gmtime, 3)
response.write gmtime
%>
ASKER
Type mismatch: '[string: "function getTimezone"]'
I had it write the variable getTimezoneOffset and it returned the whole script as a string instead of a time:
function getTimezoneOffset() { var dtmNow = new Date(); var intOffset = dtmNow.getTimezoneOffset()
Any ideas on what I might be doing wrong? It could just be because its late for me and I am not thinking straight.