Using classic asp to get server time inside javascript

dinhdu12

New Member
This one has me yanking my hair out. I placed the following classic ASP code inside the head of my document to get the server time for use in javascript... and it works, the first time. Later when the javascript calls the same function inside javascript I get the time but 2 minutes off!first time around inside the head (OK)\[code\] <% Dim servertime, d d = Now servertime = Cstr(Right("00" & Hour(d), 2) & ":" & Right("00" & Minute(d), 2) & ":" & Right("00" & Second(d), 2)) 'parse out hh:mm:ss%> <script>window.servertime = '<%=servertime%>'; // set servertime to server time duh! </script>\[/code\]Later inside a javascript function:\[code\] <% d = Now servertime = Cstr(Right("00" & Hour(d), 2) & ":" & Right("00" & Minute(d), 2) & ":" & Right("00" & Second(d), 2)) 'parse out hh:mm:ss%>window.servertime = '<%=servertime%>'; // get the server time again!\[/code\]Every time the second function runs its off by 2 minutes!
 
Back
Top