jordpw
jordpw

Reputation: 181

Python datetime module current time in HR:MIN:SEC

It seems like i should be able to find some sort of documentation on this, but everything im finding isnt working. In Python (v. 3.3) how do you get the current time in HR:MIN:SEC format using the datetime module?

Upvotes: 1

Views: 177

Answers (1)

101
101

Reputation: 8999

This should do it:

import datetime

now = datetime.datetime.now()
now.strftime('%H:%M:%S')

Other units of time can be found by using the directives found here.

Upvotes: 4

Related Questions