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))
虽然当我检索它时才会有时间到来?我想知道数据存储区的日期是什么?有线索吗?
答案 0 :(得分:2)
google app engine doc说
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.
所以要将时间转换为日期,请添加epoch time "jan 1st 1970"的开头