0

Should be quite simple: How do you remove microseconds from python timestamp doing something like:

from datetime import datetime
x = datetime.utcnow().replace(microsecond=0).timestamp()

Give result like:

1596652597.0

Is int(x) valid in this case? replace(microsecond=0) may be redundant.

martineau
  • 119,623
  • 25
  • 170
  • 301
JavaSa
  • 5,813
  • 16
  • 71
  • 121

1 Answers1

0

One idea is to use math.floor:

from datetime import datetime
from math import floor

x = floor(datetime.utcnow().timestamp())
jfaccioni
  • 7,099
  • 1
  • 9
  • 25