Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 爱奥尼亚3如何从谷歌服务器获取特定国家的当前日期/时间?_Angularjs_Firebase_Datetime_Ionic Framework_Ionic3 - Fatal编程技术网

Angularjs 爱奥尼亚3如何从谷歌服务器获取特定国家的当前日期/时间?

Angularjs 爱奥尼亚3如何从谷歌服务器获取特定国家的当前日期/时间?,angularjs,firebase,datetime,ionic-framework,ionic3,Angularjs,Firebase,Datetime,Ionic Framework,Ionic3,我正在开发IONIC 3应用程序,当按下按钮时,会有一个按钮,有关用户位置的一些信息会发送到firebase。。我还想发送当前日期/时间以及地理位置信息。。但当然不是设备的日期/时间 有什么帮助吗 这是我发送信息的功能: addAgentCoords(){ this.gpsCoordsRef$.push({ latitude: this.lat, longitude: this.long, accuracy: this.acc, altitude: this.alt, alt

我正在开发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: ??   
});

首先,您需要在变量lat 让我们考虑timestamp变量中的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)  
    });

选中“将时间戳转换为日期时间”

您可以使用以下内容:

var d = new Date();
var dd = d.getDate();
var mm = d.getMonth() + 1;
var yy = d.getFullYear();
var myDateString = dd + '_' + mm + '_' + yy; 
并将最后一个变量更改为所需的任何值