views:

37

answers:

1

Hello All

I need to save client machine time when he log in on my web application.For this i have 2 solution

  1. Using javascript

  2. Store the server time

    System.DateTime.Now.ToUniversalTime();

and ask the user in which timezone he is in

TimeZoneInfo indTimeZone = TimeZoneInfo.Local; return TimeZoneInfo.ConvertTimeFromUtc(date, TimeZoneInfo.Local);

What is the better solution to do this taks, using 1st one or 2nd one? If there is any better solution then please give me.

Thanks in Advance

A: 

To access the client's time, you have to use javascript. All server-based solutions can't access the client's clock.

So, there is no better solution, sorry.

Sven Lilienthal
Dear Sven, some time javascript may be fail due to browser compatibility.
Pankaj
Well, more likely due to the user having disabled it. But if it fails, you could always store the server's time and use that.Other possibility: Always store the server time and ask the user in which timezone he is in.
Sven Lilienthal
yes Seven, I am doing same thing.
Pankaj
I think 2nd one is the better solution
Pankaj