我必须在将来的5分钟内创建一个“ Expires”值,但是我必须以UNIX Timestamp格式提供它。到目前为止,我已经掌握了这个功能,但似乎有点。
def expires():
'''return a UNIX style timestamp representing 5 minutes from now'''
epoch = datetime.datetime(1970, 1, 1)
seconds_in_a_day = 60 * 60 * 24
five_minutes = datetime.timedelta(seconds=5*60)
five_minutes_from_now = datetime.datetime.now() + five_minutes
since_epoch = five_minutes_from_now - epoch
return since_epoch.days * seconds_in_a_day + since_epoch.seconds
是否有为我转换时间戳的模块或功能?