date time python get hour code example
Example 1: python get current hour
import datetime
now = datetime.datetime.now()
print(now.year, now.month, now.day, now.hour, now.minute, now.second)
Example 2: python datetime now only hour and minute
from datetime import datetime
hour_and_minute = datetime.now().strftime("%H:%M")
# "14:09"