티스토리 뷰

728x90
from datetime import datetime
 
time_now = datetime.now()
print(time_now, "<-- datetime now - date, time")
time_now_sec = time_now.replace(second=0)
print(time_now_sec, "<-- second removed")
time_now_sec1 = time_now.replace(second=0, microsecond=0)
print(time_now_sec1, "<-- second and microsecond removed")

https://codeigo.com/python/remove-seconds-from-datetime

 

Remove Seconds From Datetime in Python | Codeigo

This article focuses on how to remove seconds on Python datetime objects. The seconds can be removed in two ways – simply truncating seconds by turning them to 0 or by rounding off seconds into minutes. In this post, we assume you want to work with datet

codeigo.com

 

728x90
댓글