0

How to round time in format %HH:%MM:%SS.%f to %HH:%MM:%SS ?

e.g: 23:45:21.630 to 23:45:22

trusted
  • 105
  • 10

2 Answers2

1

simple remove %f

dt.strftime('%H:%M:%S')
Druta Ruslan
  • 7,171
  • 2
  • 28
  • 38
1

use strftime() formatting function. For example:

datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
Kajbo
  • 1,068
  • 3
  • 16
  • 31