diff --git a/pydantic/json.py b/pydantic/json.py
--- a/pydantic/json.py
+++ b/pydantic/json.py
@@ -105,8 +105,8 @@ def custom_pydantic_encoder(type_encoders: Dict[Any, Callable[[Type[Any]], Any]]
 
 def timedelta_isoformat(td: datetime.timedelta) -> str:
     """
-    ISO 8601 encoding for timedeltas.
+    ISO 8601 encoding for Python timedelta object.
     """
     minutes, seconds = divmod(td.seconds, 60)
     hours, minutes = divmod(minutes, 60)
-    return f'P{td.days}DT{hours:d}H{minutes:d}M{seconds:d}.{td.microseconds:06d}S'
+    return f'{"-" if td.days < 0 else ""}P{abs(td.days)}DT{hours:d}H{minutes:d}M{seconds:d}.{td.microseconds:06d}S'

diff --git a/tests/test_json.py b/tests/test_json.py
--- a/tests/test_json.py
+++ b/tests/test_json.py
@@ -46,6 +46,7 @@ class MyEnum(Enum):
         (datetime.datetime(2032, 1, 1), '"2032-01-01T00:00:00"'),
         (datetime.time(12, 34, 56), '"12:34:56"'),
         (datetime.timedelta(days=12, seconds=34, microseconds=56), '1036834.000056'),
+        (datetime.timedelta(seconds=-1), '-1.0'),
         ({1, 2, 3}, '[1, 2, 3]'),
         (frozenset([1, 2, 3]), '[1, 2, 3]'),
         ((v for v in range(4)), '[0, 1, 2, 3]'),
@@ -142,6 +143,8 @@ class Foo:
     [
         (datetime.timedelta(days=12, seconds=34, microseconds=56), 'P12DT0H0M34.000056S'),
         (datetime.timedelta(days=1001, hours=1, minutes=2, seconds=3, microseconds=654_321), 'P1001DT1H2M3.654321S'),
+        (datetime.timedelta(seconds=-1), '-P1DT23H59M59.000000S'),
+        (datetime.timedelta(), 'P0DT0H0M0.000000S'),
     ],
 )
 def test_iso_timedelta(input, output):

timedelta_isoformat does not produce correct string in some cases
### Checks

* [x] I added a descriptive title to this issue
* [x] I have searched (google, github) for similar issues and couldn't find anything
* [x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug

<!-- Sorry to sound so draconian, but every second saved replying to issues is time spend improving pydantic :-) -->

# Bug

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
   pydantic version: 1.9.0
            pydantic compiled: True
                 install path: C:\Program Files\Python310\Lib\site-packages\pydantic
               python version: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
                     platform: Windows-10-10.0.19044-SP0
     optional deps. installed: ['dotenv', 'typing-extensions']
```
# Code Demonstration bug
```py
from pydantic.json import timedelta_isoformat
from datetime import datetime

timedelta = (datetime.fromisoformat("2022-03-15 08:00:57.152735+00:00") -
             datetime.fromisoformat("2022-03-15 08:00:57.264000+00:00"))

incorrect_iso_string = timedelta_isoformat(timedelta)
# this produce "P-1DT23H59M59.888735S"  and that is incorrect according to documentation ([±]P[DD]DT[HH]H[MM]M[SS]S)
...
```


i have verified this on two diferent computers with two diferents setups (conda/regular python so it should not be problem of my enviroment)
timedelta_isoformat does not produce correct string in some cases
### Checks

* [x] I added a descriptive title to this issue
* [x] I have searched (google, github) for similar issues and couldn't find anything
* [x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug

<!-- Sorry to sound so draconian, but every second saved replying to issues is time spend improving pydantic :-) -->

# Bug

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
   pydantic version: 1.9.0
            pydantic compiled: True
                 install path: C:\Program Files\Python310\Lib\site-packages\pydantic
               python version: 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)]
                     platform: Windows-10-10.0.19044-SP0
     optional deps. installed: ['dotenv', 'typing-extensions']
```
# Code Demonstration bug
```py
from pydantic.json import timedelta_isoformat
from datetime import datetime

timedelta = (datetime.fromisoformat("2022-03-15 08:00:57.152735+00:00") -
             datetime.fromisoformat("2022-03-15 08:00:57.264000+00:00"))

incorrect_iso_string = timedelta_isoformat(timedelta)
# this produce "P-1DT23H59M59.888735S"  and that is incorrect according to documentation ([±]P[DD]DT[HH]H[MM]M[SS]S)
...
```


i have verified this on two diferent computers with two diferents setups (conda/regular python so it should not be problem of my enviroment)

tests/test_json.py::test_iso_timedelta[input2--P1DT23H59M59.000000S]
tests/test_json.py::test_encoding[input0-"ebcdab58-6eb8-46fb-a190-d07a33e9eac8"] tests/test_json.py::test_encoding[input1-"192.168.0.1"] tests/test_json.py::test_encoding[input2-"black"] tests/test_json.py::test_encoding[input3-"#010c7b"] tests/test_json.py::test_encoding[input4-"**********"] tests/test_json.py::test_encoding[input5-""] tests/test_json.py::test_encoding[input6-"**********"] tests/test_json.py::test_encoding[input7-""] tests/test_json.py::test_encoding[input8-"foo tests/test_json.py::test_encoding[input9-"::1:0:1"] tests/test_json.py::test_encoding[input10-"192.168.0.0/24"] tests/test_json.py::test_encoding[input11-"2001:db00::/120"] tests/test_json.py::test_encoding[input12-"192.168.0.0/24"] tests/test_json.py::test_encoding[input13-"2001:db00::/120"] tests/test_json.py::test_encoding[input14-"2032-01-01T01:01:00"] tests/test_json.py::test_encoding[input15-"2032-01-01T01:01:00+00:00"] tests/test_json.py::test_encoding[input16-"2032-01-01T00:00:00"] tests/test_json.py::test_encoding[input17-"12:34:56"] tests/test_json.py::test_encoding[input18-1036834.000056] tests/test_json.py::test_encoding[input19--1.0] tests/test_json.py::test_encoding[input20-[1, tests/test_json.py::test_encoding[input21-[1, tests/test_json.py::test_encoding[<genexpr>-[0, tests/test_json.py::test_encoding[this tests/test_json.py::test_encoding[input24-12.34] tests/test_json.py::test_encoding[input25-{"a": tests/test_json.py::test_encoding[MyEnum.foo-"bar"] tests/test_json.py::test_encoding[^regex$-"^regex$"] tests/test_json.py::test_path_encoding tests/test_json.py::test_model_encoding tests/test_json.py::test_subclass_encoding tests/test_json.py::test_subclass_custom_encoding tests/test_json.py::test_invalid_model tests/test_json.py::test_iso_timedelta[input0-P12DT0H0M34.000056S] tests/test_json.py::test_iso_timedelta[input1-P1001DT1H2M3.654321S] tests/test_json.py::test_iso_timedelta[input3-P0DT0H0M0.000000S] tests/test_json.py::test_custom_encoder tests/test_json.py::test_custom_iso_timedelta tests/test_json.py::test_con_decimal_encode tests/test_json.py::test_json_encoder_simple_inheritance tests/test_json.py::test_json_encoder_inheritance_override tests/test_json.py::test_custom_encoder_arg tests/test_json.py::test_encode_dataclass tests/test_json.py::test_encode_pydantic_dataclass tests/test_json.py::test_encode_custom_root tests/test_json.py::test_custom_decode_encode tests/test_json.py::test_json_nested_encode_models tests/test_json.py::test_custom_encode_fallback_basemodel tests/test_json.py::test_custom_encode_error tests/test_json.py::test_recursive