diff --git a/homeassistant/helpers/template.py b/homeassistant/helpers/template.py index 4c6888cbf2f..ca2828c4402 100644 --- a/homeassistant/helpers/template.py +++ b/homeassistant/helpers/template.py @@ -1462,9 +1462,7 @@ def timestamp_custom(value, date_format=DATE_STR_FORMAT, local=True, default=_SE def timestamp_local(value, default=_SENTINEL): """Filter to convert given timestamp to local date/time.""" try: - return dt_util.as_local(dt_util.utc_from_timestamp(value)).strftime( - DATE_STR_FORMAT - ) + return dt_util.as_local(dt_util.utc_from_timestamp(value)).isoformat() except (ValueError, TypeError): # If timestamp can't be converted if default is _SENTINEL: @@ -1476,7 +1474,7 @@ def timestamp_local(value, default=_SENTINEL): def timestamp_utc(value, default=_SENTINEL): """Filter to convert given timestamp to UTC date/time.""" try: - return dt_util.utc_from_timestamp(value).strftime(DATE_STR_FORMAT) + return dt_util.utc_from_timestamp(value).isoformat() except (ValueError, TypeError): # If timestamp can't be converted if default is _SENTINEL: diff --git a/tests/helpers/test_template.py b/tests/helpers/test_template.py index f1dc740a068..1a8bf8e526b 100644 --- a/tests/helpers/test_template.py +++ b/tests/helpers/test_template.py @@ -692,7 +692,7 @@ def test_timestamp_custom(hass): def test_timestamp_local(hass): """Test the timestamps to local filter.""" - tests = {None: None, 1469119144: "2016-07-21 16:39:04"} + tests = {None: None, 1469119144: "2016-07-21T16:39:04+00:00"} for inp, out in tests.items(): assert ( @@ -859,8 +859,8 @@ def test_timestamp_utc(hass): now = dt_util.utcnow() tests = { None: None, - 1469119144: "2016-07-21 16:39:04", - dt_util.as_timestamp(now): now.strftime("%Y-%m-%d %H:%M:%S"), + 1469119144: "2016-07-21T16:39:04+00:00", + dt_util.as_timestamp(now): now.isoformat(), } for inp, out in tests.items():