.time()

Published Jun 7, 2022
Contribute to Docs

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

Syntax

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:

Code
Output
Loading...

All contributors

Looking to contribute?

Learn Python on Codecademy