3.Why does "jan 1st 1970" gets added in the startime field in datastore when I am doing the below statements?
3.当我在做以下语句时,为什么“jan 1st 1970”会被添加到数据存储区的startime字段中?
(hour,min) = self.request.get('starttime').split(":")
#if either of them is null or empty string then int will throw exception
if hour and min :
datastoremodel.starttime = datetime.time(int(hour), int(min))
Although when I retrieve it only time comes through? I wonder what date is doing in datastore? Any clues?
虽然当我检索它时,只有时间过去了?我想知道数据存储区的日期是什么?有线索吗?
1 个解决方案
#1
google app engine doc says
谷歌应用引擎文档说
class TimeProperty(verbose_name=None, auto_now=False, auto_now_add=False, ...)
A time property, without a date. Takes a Python standard library datetime.time value. See DateTimeProperty for more information.
Value type: datetime.time. This is converted to a datetime.datetime internally.
so to convert time to a date , start of epoch time "jan 1st 1970" is added
因此,为了将时间转换为日期,添加了纪元时间“1970年1月1日”的开始