代码之家  ›  专栏  ›  技术社区  ›  Jiacai Liu

在emacs(elisp)中解析unix时间戳

  •  2
  • Jiacai Liu  · 技术社区  · 7 年前

    鉴于 1525505457 ,返回日期对象( Sat May 05 2018 15:30:57 GMT+0800 (CST) )代表它。

    http://ergoemacs.org/emacs/elisp_parse_time.html 本文仅介绍如何将日期格式化为unix时间,而不是其他方式。

    1 回复  |  直到 7 年前
        1
  •  0
  •   Alex Ott    7 年前

    结合使用 decode-time & seconds-to-time ,如下所示:

    (decode-time (seconds-to-time 1525505457))
    => (57 30 9 5 5 2018 6 t 7200)
    

    同一模块, time-date.el 具有其他转换为时间对象的功能,如字符串等:

    (decode-time (date-to-time "2018-05-05T12:33:05Z"))
    => (5 33 14 5 5 2018 6 t 7200)