From d828449611ddd44fef5bc1a2e69ae8a1cac431f2 Mon Sep 17 00:00:00 2001
From: Arthur Kepler <dev@arthurk.com>
Date: Mon, 7 Aug 2017 11:33:25 -0700
Subject: [PATCH] Corrects default arg format used by datetime filter (#27612)

This ensures the default datetime format matches that of
datetime.datetime. Docs updated to match as well.
---
 docs/docsite/rst/playbooks_filters.rst | 4 ++--
 lib/ansible/plugins/filter/core.py     | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/docs/docsite/rst/playbooks_filters.rst b/docs/docsite/rst/playbooks_filters.rst
index 98a2f2b68bb..e76a3993991 100644
--- a/docs/docsite/rst/playbooks_filters.rst
+++ b/docs/docsite/rst/playbooks_filters.rst
@@ -654,8 +654,8 @@ To make use of one attribute from each item in a list of complex variables, use
 
 To get date object from string use the `to_datetime` filter, (new in version in 2.2)::
 
-    # get amount of seconds between two dates, default date format is %Y-%d-%m %H:%M:%S but you can pass your own one
-    {{ (("2016-08-04 20:00:12"|to_datetime) - ("2015-10-06"|to_datetime('%Y-%d-%m'))).seconds  }}
+    # get amount of seconds between two dates, default date format is %Y-%m-%d %H:%M:%S but you can pass your own one
+    {{ (("2016-08-14 20:00:12"|to_datetime) - ("2015-12-25"|to_datetime('%Y-%m-%d'))).seconds  }}
 
 
 Combination Filters
diff --git a/lib/ansible/plugins/filter/core.py b/lib/ansible/plugins/filter/core.py
index 4d7b2b25db0..e3e01c9d67e 100644
--- a/lib/ansible/plugins/filter/core.py
+++ b/lib/ansible/plugins/filter/core.py
@@ -125,7 +125,7 @@ def to_bool(a):
     return False
 
 
-def to_datetime(string, format="%Y-%d-%m %H:%M:%S"):
+def to_datetime(string, format="%Y-%m-%d %H:%M:%S"):
     return datetime.strptime(string, format)