Forum Moderators: open

Message Too Old, No Replies

getting time offset of a visitor

         

lindajames

12:29 am on Feb 18, 2004 (gmt 0)

10+ Year Member



hi,

I need to calculate the offset between a visitors time and my server time. I've used a javscript to get the users time and then post the time to a asp script and store the visitors time as a variable. But what i need help in doing is calculating the difference between the visitors time and my server time. So, for example if the server time is 15:00 and the visitors time is 13:00 then the offset is -2 and if the servers time is 15:00 and the visitors time is 17:00 then the offset is +2

the format of the time that is detected of the visitor is like this: 1:09:22 A.M. and 1:09:22 P.M.

any help would be very much appreciated.

cheers
linda

mattglet

3:16 am on Feb 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The DateDiff Function [devguru.com]

-Matt

lindajames

12:26 pm on Feb 18, 2004 (gmt 0)

10+ Year Member



that seems to only calculate the difference between two dates, i want to calcualte the different between two times

defanjos

2:46 pm on Feb 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



lindajames,

Try this, it might help you:
h**p://support.microsoft.com/default.aspx?scid=kb;en-us;130514

mattglet

7:41 pm on Feb 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Linda,
Jumped the gun on that one... my fault.

-Matt

Xoc

9:13 pm on Feb 18, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



DateDiff will work on times as well. But if you want the difference in times, you can just subtract one from the other and convert the result into a Date data type.


Dim dtFirst
Dim dtSecond

dtSecond = Time
dtFirst = #4:14#

Response.Write(CDate(dtSecond - dtFirst))

Remember that times are just fractions of a day. 6 a.m. is .25, noon is .5, and 6 p.m. is .75. So you can just subtract one from the other, which creates a new fraction. When that fraction is converted back into the date format, it becomes a time.

Added: This is for standard ASP. For ASP.NET, the time format is different, and you will need execute a method to do time calculations.

[edited by: Xoc at 6:49 am (utc) on Feb. 19, 2004]

mattglet

4:42 am on Feb 19, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



informative info Xoc. very nice.

-Matt