Meena
Meena

Reputation: 715

Get client timezone information in server

I have a web api project. I need to know the timezone from where I recieve calls to my apis. I have a method which expects a DateTime object as a parameter. I searched if I can somehow get the timezone information from this but apparently it can't be done. For some reason I cant pass the timezone information from client side. Can this be done? Let me know if you need any other information.

Upvotes: 0

Views: 1109

Answers (1)

Vivek Mishra
Vivek Mishra

Reputation: 1804

Get the Ip Address of your request i.e. Request.UserHostAddress and call this api-

http://ip-api.com/json/yourIpAddress

this will give you all the information as json response like

{
"as": "AS24560 Bharti Airtel Ltd., Telemedia Services",
"city": "Lucknow",
"country": "India",
"countryCode": "IN",
"isp": "Airtel Broadband",
"lat": 26.85,
"lon": 80.9167,
"org": "Airtel Broadband",
"query": "122.160.15.23",
"region": "UP",
"regionName": "Uttar Pradesh",
"status": "success",
"timezone": "Asia/Kolkata",
"zip": "226010"
}

Upvotes: 4

Related Questions