diff --git a/README.md b/README.md
index e8f74e0..6672013 100644
--- a/README.md
+++ b/README.md
@@ -55,9 +55,9 @@ Function Reference
The supported list of display functions is shown below:
-- `moment(timestamp=None, local=False).format(format_string)`
-- `moment(timestamp=None, local=False).fromNow(no_suffix = False)`
-- `moment(timestamp=None, local=False).fromTime(another_timesatmp, no_suffix = False)`
+- `moment(timestamp=None, local=False).format(format_string=None)`
+- `moment(timestamp=None, local=False).fromNow(no_suffix=False)`
+- `moment(timestamp=None, local=False).fromTime(another_timesatmp, no_suffix=False)`
- `moment(timestamp=None, local=False).calendar()`
- `moment(timestamp=None, local=False).valueOf()`
- `moment(timestamp=None, local=False).unix()`
@@ -69,6 +69,11 @@ Auto-Refresh
All the display functions take an optional `refresh` argument that when set to `True` will re-render timestamps every minute. This can be useful for relative time formats such as the one returned by the `fromNow()` or `fromTime()` functions. By default refreshing is disabled.
+Default Format
+--------------
+
+The `format()` function can be invoked without arguments, in which case a default format of ISO8601 defined by the moment.js library is used. If you want to set a different default, you can set the `MOMENT_DEFAULT_FORMAT` variable in the Flask configuration. Consult the [moment.js format documentation](http://momentjs.com/docs/#/displaying/format/) for a list of acepted tokens.
+
Internationalization
--------------------
diff --git a/flask_moment.py b/flask_moment.py
index 2045500..a2ae4bb 100644
--- a/flask_moment.py
+++ b/flask_moment.py
@@ -42,8 +42,12 @@ def include_moment(version=default_moment_version, local_js=None,
'crossorigin="anonymous">\n' \
% (version, js_filename, sri)
+ default_format = ''
+ if 'MOMENT_DEFAULT_FORMAT' in current_app.config:
+ default_format = '\nmoment.defaultFormat = "%s";' % \
+ current_app.config['MOMENT_DEFAULT_FORMAT']
return Markup('''%s''' % js) # noqa: E501
+''' % (js, default_format)) # noqa: E501
@staticmethod
def include_jquery(version=default_jquery_version, local_js=None,
@@ -119,8 +123,8 @@ def _render(self, format, refresh=False):
'style="display: none">%s') %
(t, format, int(refresh) * 60000, t))
- def format(self, fmt, refresh=False):
- return self._render("format('%s')" % fmt, refresh)
+ def format(self, fmt=None, refresh=False):
+ return self._render("format('%s')" % (fmt or ''), refresh)
def fromNow(self, no_suffix=False, refresh=False):
return self._render("fromNow(%s)" % int(no_suffix), refresh)
diff --git a/tests/test_flask_moment.py b/tests/test_flask_moment.py
index d454a9e..c0ad46c 100644
--- a/tests/test_flask_moment.py
+++ b/tests/test_flask_moment.py
@@ -85,8 +85,15 @@ def test_include_moment_renders_properly(self, app, moment):
ts = str(render_template_string("{{ moment.include_moment() }}"))
assert "