Forum Moderators: open
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
Dim dtFirst
Dim dtSeconddtSecond = 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]