[erlang-questions] formatting timestamps
Joel Reymont
joelr1@REDACTED
Mon Jun 13 18:46:47 CEST 2011
On Jun 13, 2011, at 8:39 PM, Bob Ippolito wrote:
> http://www.erlang.org/doc/man/calendar.html#now_to_universal_time-1
This does the trick, courtesy of Filipe Manana:
timestamp(Now) ->
{_, _, Micros} = Now,
{{YY, MM, DD}, {Hour, Min, Sec}} = calendar:now_to_local_time(Now),
io_lib:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w.~p",
[YY, MM, DD, Hour, Min, Sec, Micros]).
--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------
More information about the erlang-questions
mailing list