如何从相同时区和不同时间从googleapi获取正确的日期和时间 [英] How do I get correct date and time from googleapi from same timezone and different time

查看:94
本文介绍了如何从相同时区和不同时间从googleapi获取正确的日期和时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我正在创建一项服务,将纬度和经度以及时间戳作为输入并使用GoogleAPI并向我发送正确的时区。通过使用这个时区,我可以获得该纬度的日期和时间。



工作正常,但现在我面临一些我无法解决的问题它。

我的问题是迪拜和卡塔尔在TimeZone的时间不同。因此,当我根据TimeZone计算时间时,两者都显示相同的时间。所以我需要一些解决方案。



我尝试过:



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;
   }









这是付费的GoogleAPI,我怀疑为什么需要第三个参数。现在我从系统日期发送当前秒作为第三个参数。

如何区分具有相同时区的时间。





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.

推荐答案

根据世界时间服务器 [ ^ ],迪拜和卡塔尔位于不同的时区。 Google只能根据提供的经度进行猜测,因此您可能需要将值调整为两种状态的相反边缘。
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.


这篇关于如何从相同时区和不同时间从googleapi获取正确的日期和时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆