0

How can I get the user's Date time in asp.net?

If the user's machine time is not configured correctly then JavaScript is useless. Is there any other solution?

War10ck
  • 12,387
  • 7
  • 41
  • 54
  • So you want to get client machine's date & time? – Chirag Vidani Jan 27 '14 at 06:17
  • yes i want a good smart approach towards getting client current date time in asp.net which is un-ambiguous. mostly client computers date time is not configured correctly. please give me smart solution. – Abdul Nasir Khayam Jan 27 '14 at 06:22
  • possible duplicate of [How to get client date and time in ASP.NET?](http://stackoverflow.com/questions/274826/how-to-get-client-date-and-time-in-asp-net) – Devraj Gadhavi Jan 27 '14 at 07:01

2 Answers2

0

If you're trying to display the user's local date/time, you could detect/request for their timezone and then calculate their local time from there. Remember to include DST preferences to ensure accuracy. There are plenty of forums out there with this feature, such as this one.

JW Lim
  • 1,794
  • 3
  • 21
  • 41
  • yes. first of all, user will be purchase some thing with his incorrect time configured on computer. then javascript methodology i used is meaningless. so IP is i think only solution for that. get location by IP and through web service get current time basis on location. – Abdul Nasir Khayam Jan 27 '14 at 06:36
  • You might've misunderstood my reply. The solution I mentioned does not involve getting the time on the client's machine. I mentioned detecting for their timezone, and that is typically achieved by using their IP address. Or you could be lazy and just request for their timezone, which I also mentioned and edited my answer to include an example. – JW Lim Jan 27 '14 at 06:41
0

Lookup his IP, and try to get the timezone based on the IP, then you can get somewhat accurate time of the user, unless the user is using a proxy to browse your website. Making the user access your site via https:// can also help, if he tries to change the dates too drastically, as it will throw a SSL certificate error in his browser.

Aby
  • 1,916
  • 1
  • 12
  • 18