为什么数据存储日期时间在appengine控制台和appengine仪表板中看起来不同? [英] Why do Datastore datetimes look different in appengine console vs appengine dashboard?

查看:108
本文介绍了为什么数据存储日期时间在appengine控制台和appengine仪表板中看起来不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常简单的NDB模型,我为其输入了出生日期:

  class联系(ndb.Model):
first_name = ndb.StringProperty()
last_name = ndb.StringProperty()
dob = ndb.DateTimeProperty()
contact1_dob = datetime.strptime( 'date / $ d $ b contact1 = Contact(first_name ='Homer',last_name ='Simpson',dob = contact1_dob)
contact1_result = contact1.put()

加载到数据存储区可以正常工作,当我查看通过Google Appengine控制台的数据 https://appengine.google.com/ DOB看起来非常完美,例如1989-12-17 00:00:00



但是当我通过appengine控制台 https://console.developers.google.com DOB落后四个小时(我在纽约)例如1989-12-16 20:00:00



我只能猜测这是一个时区问题,但如果它不是仪表板和控制台中的日期匹配?



另外,如果我通过.get()调用检索实体并查看原始数据,那么日期与我输入的完全相同,例如1989-12-17 00:00:00,这正是我想要的。



那么为什么appengine控制台不能准确地呈现数据存储日期?

$ b 旧的数据查看器始终显示为UTC,新控制台尝试在您的时区中显示。 日期时间始终是你的应​​用程序内部的UTC(所以如果你做.put()或.get()它将被保存为UTC)

所以你正在设置它在UTC的午夜时分在您的应用程序中进行放置,然后在新的控制台中查看它,该控制台在前一天向您显示20:00:00T(东部标准时间晚上8点)

在使用Remote API的时区周围存在报告问题......不确定您是否将它用于任何投放/获取......也可能发挥作用(但我认为他们有那些现在主要是固定的)


I have a very simple NDB model for which I'm entering Date-of-Birth for a user:

class Contact(ndb.Model):
    first_name= ndb.StringProperty()
    last_name= ndb.StringProperty()
    dob = ndb.DateTimeProperty()
contact1_dob = datetime.strptime('12/17/1989', "%m/%d/%Y").date()
contact1 = Contact(first_name='Homer', last_name='Simpson', dob=contact1_dob )
contact1_result = contact1.put()

Loading into the datastore works fine, and when I look at the data via the Google Appengine dashboard https://appengine.google.com/ the DOB looks perfect e.g. 1989-12-17 00:00:00

But when I look at the data via the appengine console https://console.developers.google.com the DOB is four hours behind (I'm in New York) e.g. 1989-12-16 20:00:00

I can only guess this is a timezone issue but if it were wouldn't the dates in both the dashboard and the console match?

Also if I retrieve the entity via a .get() call and view the raw data the date is exactly as I entered it, e.g. 1989-12-17 00:00:00, which is what I want.

So why is the appengine console not rendering datastore dates accurately?

解决方案

The old dataviewer always displays as UTC, the new console attempts to display in your timezone. Datetimes are always UTC from inside your application (so if you do a .put() or .get() it will be saved as UTC)

So you are setting it at midnight UTC inside your app and doing a put, then looking at it in the new console which is showing you 20:00:00T (8pm EST) the day before

There have been reported issues around timezones when using Remote API... not sure if you're using that for any of your puts/gets... might also play a part (but I thought they had those mostly fixed by now)

这篇关于为什么数据存储日期时间在appengine控制台和appengine仪表板中看起来不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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