1

We have one requirement where depending upon the clients local machine where site is being accessed we need to get its local date and time. Our Server is hosted in the US and when any asian user hits the site between 12.00 AM to 11.30AM on 30th Nov he will not able to see latest post as US still have 29th Nov, So I need to access clients local date and time to add some business logic. Is their any way to implement this?

Raj
  • 33
  • 1
  • 8
  • 1
    Yes, you use Javascript. It seems like you're not so interested in the local date and time as the local time zone - there are many questions on SO about finding the local time zone in Javascript. – Jon Skeet Nov 30 '16 at 06:51
  • Take a look:[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) – huse.ckr Nov 30 '16 at 06:51
  • 1
    Possible duplicate of http://stackoverflow.com/questions/13717479/how-to-get-client-current-date-and-time-in-asp-net – Amey Kamat Nov 30 '16 at 06:51
  • Actually something is really screwed up in that whole logic. Lets say I'm user "smartass" and I intentionally set my local datetime to a totally wrong value. Do you intend to serve me content based on this datetime? Serverside should not care about US or whatever (or explicitely take care of it), but work with UTC times for all requests and potentially translate to client timezone on delivery. – grek40 Nov 30 '16 at 07:24
  • @JonSkeet Thanks for your response :), Javascript approach works fine, but if user intentionally changes its time zone and date time then it will not give the correct result. – Raj Dec 02 '16 at 07:35
  • @Raj: Well what is "correct" in that situation? It's correct by the information they're deliberately giving you. If you mean that you want to track the user's physical location in an unforgeable way, I'd say that's a bit on the invasive side, even if it were feasible... – Jon Skeet Dec 02 '16 at 07:54

0 Answers0