Click here to Skip to main content
16,016,623 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I am creating a service that take Latitude and longitude and Timestamp as input and use GoogleAPI and send me correct timeZone. By using this timezone I am able to get the date and time for that lat long.

Its working fine but Now I am facing some problem that I am unable to resolve it.
My problem is Both Dubai and Qatar is at same TimeZone with different time. so when I calculate time as per TimeZone both are showing same time. So I need some solution for it.

What I have tried:

protected string getTimeZoneFroPaidApi(string latitude, string longitude, int TimeStamp)
   {
       string str = "";
       try
       {
           XElement xelement = XElement.Load(string.Format("https://maps.googleapis.com/maps/api/timezone/xml?location={0},{1}×tamp={2}&key=*********", (object)latitude, (object)longitude, (object)TimeStamp));
           str = !(xelement.Element((XName)"status").Value == "OK") ? "Error: " + xelement.Element((XName)"status").Value : string.Format("{0}", (object)xelement.Element((XName)"raw_offset").Value);
       }
       catch (Exception ex)
       {
           Logger.WriteLogWS(ex, "V2_SERVICE", "GET_TIME_ZONE");
       }
       return str;
   }




It is a paid GoogleAPI and I have doubt why the third parameter is required. Now I am sending current Second from System date as third parameter.
How can I differentiate the time with same timezone.
Posted
Updated 11-Jul-17 21:58pm

1 solution

According to World Time Server[^], Dubai and Qatar are in different time zones. Google can only guess based on the longitude provided, so you probably need to adjust the values to the opposite edges of the two states.
 
Share this answer
 
Comments
bigyan sahoo 12-Jul-17 5:07am    
I want to know why we need timestamp value and how can I use timestamp value. Now I am sending current second from server date. SO it is showing same date and time for both qatar and Dubai.

Response I got for Both
<timezoneresponse>
<status>OK
<raw_offset>14400.0000000
<dst_offset>0.0000000
<time_zone_id>Asia/Dubai
<time_zone_name>Gulf Standard Time



<timezoneresponse>
<status>OK
<raw_offset>14400.0000000
<dst_offset>0.0000000
<time_zone_id>Asia/Qatar
<time_zone_name>Gulf Standard Time
Richard MacCutchan 12-Jul-17 5:15am    
You would need to talk to Google about this, it seems they have different information about the two states.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900