The datetime.time() method returns a time in seconds that has passed since the epoch set on the computer.


datetime.time(hour=0, minute=0, second=0, microsecond=0, tzinfo=None)

The epoch is usually set as January 1, 1970, 00:00:00 (UTC) on most operating systems, excluding any leap seconds.

Codebyte Example

The time can be retrieved and stored in a variable as shown below:

Edit this page on GitHub


Interested in helping build Docs? Read the Contribution Guide or share your feedback form.

Learn Python on Codecademy