TimeDelta.resolution

The timeDelta.resolution attribute represents the smallest quantity of time that can be represented through the class datetime.timedelta. The Python example prints the current value of timedelta.resolution.

Timedelta Updated 6 Aug 2021 1 min read

Overview

  • The timedelta class represents a quantity of time.
  • The attribute timedelta.resolution is the smallest quantity that can be represented using the datetime.timedelta class.
  • The value of timedelta.resolution is currently one microsecond.
  • A microsecond is one millionth of one second.

Example:

python
# Example Python program that prints the

            # smallest quantity of time supported

            # by the class timedelta

            from datetime import timedelta

# Construct a duration of 1 hours, 2 minutes, 3 seconds and

            # 4 microseconds and print it

            someTime = timedelta(hours=1, minutes=2, seconds=3, microseconds=4)

            print(someTime)

            print(type(someTime))

# Print the smallest supported time duration

            print(timedelta.resolution)

            print(type(timedelta.resolution))

Output

Output
1:02:03.000004

<class 'datetime.timedelta'>

0:00:00.000001

<class 'datetime.timedelta'>