`

python 使用本地时区

阅读更多
def getEpubInfo(self):
        sql = 'select pubid, publish_time,e_type  from p_epub_info where is_valid=1'
        self.cur.execute(sql)
        datas = self.cur.fetchall();
        result=[]
        for data in datas:
            print data[0],'\t',data[1],'\t',type(data[1])
            timelong = calendar.timegm(data[1].utctimetuple())
            timelong0 = int(time.mktime(data[1].timetuple()))
            print timelong,timelong0
            print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timelong))#utc
            #time.localtime(timelong0) == type(data[1])
            print time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(timelong0))#本地时区
            epubInfo = EpubInfo.EpubInfo(int(data[2]),str(data[1]),int(data[0]),int(time.mktime(data[1].timetuple())));
            result.append(epubInfo)
        return result
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics