python 几小时前\几分前换算时间戳

1.几小时前换算时间戳

        now_time = int(time.time())
        print(now_time)
        timeArray = datetime.datetime.utcfromtimestamp(time_now1)
        print(timeArray)
        # 加8小时时区,再减几小时前时间
        datetime = timeArray +(datetime.timedelta(hours=8)) - datetime.timedelta(hours=3)
        print(datetime)
posted @ 2021-08-12 17:33  莫贞俊晗  阅读(240)  评论(0编辑  收藏  举报