Chinaunix

标题: 【时间字符串】 [打印本页]

作者: shijiang1130    时间: 2015-09-19 20:28
标题: 【时间字符串】
  1. formated_timestamp() ->
  2.     {Date, Time}   = erlang:localtime(),
  3.     {YYYY,MM,DD}   = Date,
  4.     {Hour,Min,Sec} = Time,
  5.     FormatDate =
  6.         io_lib:format("~.4w-~.2.0w-~.2.0w ~.2.0w:~.2.0w:~.2.0w",
  7.                       [YYYY,MM,DD,Hour,Min,Sec]),
  8.     lists:flatten(FormatDate).
复制代码

作者: shijiang1130    时间: 2015-09-19 20:28
  1. 13> mytest:formated_timestamp().
  2. "2015-09-19 20:27:46"
复制代码

作者: patagonia2    时间: 2015-09-23 20:24
好啊,支持一下啊
非常感谢。




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2