mongo shell中的时间不匹配 [英] Time mismatch in mongo shell

查看:80
本文介绍了mongo shell中的时间不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我获得日期对象并将其打印在mongo shell中时,它将显示两个不同的时间,如下所示:

>新Date()
2012年2月6日星期一18:49:40 GMT + 0530(IST)
> printjson({created_at:new Date()})
{created_at:ISODate("2012-02-06T13:19:40.313Z")}

When I get the date object and print it in mongo shell, it display two different time as follows:

>new Date()
Mon Feb 06 2012 18:49:40 GMT+0530 (IST)
>printjson({created_at: new Date()})
{ created_at : ISODate("2012-02-06T13:19:40.313Z") }

两次不同,我错了.

推荐答案

时间没有不同,它们是完全一样的!它只是在不同时区表示的同一时间. ISODate中的"Z"表示"UTC"(或有人尝试称呼它为:GMT).您正在使用格林尼治标准时间(GMT + 0530)的IST(我猜是印度标准时间). 18:49:40 @ GMT + 5:30与13:19 @ GMT完全相同.

The times are not different, they are exactly the same! It's merely the same time expressed in different timezones. The "Z" in ISODate means "UTC" (or as some people try to call it: GMT). You're on IST (Indian Standard Time I guess) which is at GMT+0530. 18:49:40 @ GMT+5:30 is exactly the same as 13:19 @ GMT.

当我运行您在shell上显示的相同代码时,我得到:

When I run the same code you shown on the shell, I get:


> new Date()
ISODate("2012-02-06T13:34:10.667Z")

如您所见,它也带有"Z".也许您正在运行旧版本的Shell?

As you can see, that is also with "Z". Perhaps you're running an older version of the shell?

欢呼声, 德里克

这篇关于mongo shell中的时间不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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