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
  • 9

2 Answers2

1

simple remove %f

dt.strftime('%H:%M:%S')
Druta Ruslan
  • 6,597
  • 2
  • 25
  • 35
1

use strftime() formatting function. For example:

datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
Kajbo
  • 878
  • 3
  • 12
  • 31