[erlang-questions] How to format a local timestamp?

Colm Dougan <>
Sat Oct 3 17:58:56 CEST 2009


On Fri, Oct 2, 2009 at 11:05 PM, Cameron Kerr <> wrote:
> I must surely be missing something in the documentation, but I cannot find
> any easy way to generate a human-readable timestamp easily in Erlang.

erlydtl contains a self-contained date formatting module :
    http://erlydtl.googlecode.com/svn/trunk/src/erlydtl/erlydtl_dateformat.erl

e.g.

Eshell V5.6.5  (abort with ^G)
1> erlydtl_dateformat:format(erlang:localtime(),  "Y-m-d H:i:s").
"2009-10-03 16:55:40"

It implements most of the tags of the original django date formatting,
(which itself is based on http://php.net/date) which is documented
here :
   http://docs.djangoproject.com/en/dev/ref/templates/builtins/#now

The erlang implementation lacks some of the time-zone formatting calls.

Colm


More information about the erlang-questions mailing list