【问题标题】:IONIC 3 how to get current date/time from google servers for specific country?IONIC 3 如何从特定国家/地区的谷歌服务器获取当前日期/时间?
【发布时间】:2018-03-12 19:20:28
【问题描述】:

我正在开发 IONIC 3 应用程序,我有一个按钮 按下它时,有关用户位置的一些信息会发送到 firebase .. 我也想发送当前日期/时间和地理位置信息 .. 但是当然不是设备的日期/时间。

有什么帮助吗?

这是我发送信息的功能:

addAgentCoords(){
this.gpsCoordsRef$.push({
  latitude: this.lat,
  longitude: this.long,
  accuracy: this.acc,
  altitude: this.alt,
  altitudeAccuracy: this.altacc,
  speed: this.spd
  //dateTime: ??   
});

【问题讨论】:

    标签: angularjs firebase datetime ionic-framework ionic3


    【解决方案1】:

    你可以这样使用:

    var d = new Date();
    var dd = d.getDate();
    var mm = d.getMonth() + 1;
    var yy = d.getFullYear();
    var myDateString = dd + '_' + mm + '_' + yy; 
    

    并将最后一个变量更改为您想要的任何内容。

    【讨论】:

      【解决方案2】:

      首先,您需要在 lat 等变量中从地理位置插件中添加时间戳 让我们考虑 timestamp 变量中的时间戳

      那就试试吧

      this.gpsCoordsRef$.push({
            latitude: this.lat,
            longitude: this.long,
            accuracy: this.acc,
            altitude: this.alt,
            altitudeAccuracy: this.altacc,
            speed: this.spd,
            dateTime: new Date(timestamp)  
          });
      

      检查将时间戳转换为日期时间 click here

      【讨论】:

        猜你喜欢
        • 2015-07-20
        • 1970-01-01
        • 2017-04-25
        • 2013-11-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多