我正在使用Firebase作为服务器并以flutter为前端开发应用程序。 情况是我上载带有时间戳的新文档,其中包含当前时间,如下所示:
"timestamp": DateTime.now().toString(),
当我以本地主机运行它时,我看到该文档也保存了当前时间,但是当我在cloude服务器上运行它时,它节省了+3个小时。我知道它与UTC有关,在我国,UTC为+3。服务器上的行是:
console.log(req.body.timestamp);
let timeStamp = new Date(req.body.timestamp);
console.log(timeStamp);
for example the prints on localhost to that string 2020-05-23 23:16:03.735472
was:
> 2020-05-23 23:16:03.735472
> 2020-05-23T20:16:03.735Z
但是从服务器上是:
> 2020-05-23 23:16:03.735472
> 2020-05-23T23:16:03.735Z
为什么会发生?