Mike.C
Mike.C

Reputation: 11

Python 2 UTC time just print the hour minutes and seconds

In python 2 can you please tell me how to just print hours, minutes and seconds with UTC

Trying to avoid printing out the date Thanks

import datetime  
import pytz
T7 = datetime.datetime.utcnow() 
print(T7)

Upvotes: 0

Views: 2993

Answers (1)

Colwin
Colwin

Reputation: 2685

Have a look at the documentation at https://docs.python.org/3/library/datetime.html#strftime-and-strptime-behavior

The code below will give you what you need.

datetime.datetime.utcnow().strftime("%H:%M:%S")

Upvotes: 1

Related Questions