在数据存储区GAE中添加时间时,会在后台添加日期

时间:2009-07-02 06:55:19

标签: python google-app-engine datetime

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))

虽然当我检索它时才会有时间到来?我想知道数据存储区的日期是什么?有线索吗?

1 个答案:

答案 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"的开头