Search code examples
pythondatetimetimestamputc

time difference between utc and python datetime() time


with python's datetime package, I'm seeing a ~8min time difference between datetime.now().timestamp() and datetime(year, month, day, hour, minute, second, [tz]).timestamp(), when I put now's time in the latter formula. With or without the tz, which is timezone, the 8min difference stays there. Anyone can explain where it went wrong? Thanks!


Solution

  • You can (and should) use tzinfo.localize() instead.

    https://stackoverflow.com/a/6411149/1114412