diff --git a/docker/utils/utils.py b/docker/utils/utils.py index 759ddd2f1..dbd513030 100644 --- a/docker/utils/utils.py +++ b/docker/utils/utils.py @@ -5,7 +5,7 @@ import os.path import shlex import string -from datetime import datetime +from datetime import datetime, timezone from packaging.version import Version from .. import errors @@ -394,8 +394,8 @@ def convert_filters(filters): def datetime_to_timestamp(dt): - """Convert a UTC datetime to a Unix timestamp""" - delta = dt - datetime.utcfromtimestamp(0) + """Convert a datetime to a Unix timestamp""" + delta = dt.astimezone(timezone.utc) - datetime(1970, 1, 1, tzinfo=timezone.utc) return delta.seconds + delta.days * 24 * 3600