zoukankan      html  css  js  c++  java
  • erlang时间操作

    erlang 时间函数操作
    1.本地时间
      local_time() ->
        calendar:local_time().

    2.UTC世界时间
      world_time() ->
        calendar:universal_time().

    3.日期转换成秒数
      calendar:datetime_to_gregorian_seconds({{2019,4,3},{17,5,44}}).

    4.两个日期大小对比
      calendar:datetime_to_gregorian_seconds({{2019,4,3},{17,5,44}}) - calendar:datetime_to_gregorian_seconds({{2019,5,3},{17,5,44}})

    5.秒数转换成日期
      calendar:gregorian_seconds_to_datetime(63721530344).

    6.获得时间戳的方法
     (1)%时间转时间戳,格式:{{2013,11,13}, {18,0,0}}
      DateTime = calendar:universal_time(). %%必须是UTC世界时间
      datetime_to_timestamp(DateTime) ->
        calendar:datetime_to_gregorian_seconds(DateTime) - calendar:datetime_to_gregorian_seconds({{1970,1,1}, {0,0,0}}).
     (2)%os:timestamp() 操作系统时间
      timestamp() ->
        {M, S, _} = os:timestamp(),
        M * 1000000 + S.
     (3)%erlang:now() erlang虚拟机时间
      timestamp() ->
      {M, S, _} = erlang:now(),
      M * 1000000 + S.

  • 相关阅读:
    5.数组的使用,最值和反转
    4.下标越界及小结
    3.数组的三种初始化及简单内存分析
    html5版 音乐播放器
    百度网盘搜索
    HTML5扩展之微数据与丰富网页摘要
    Java 学习文章汇总
    业余草
    Catalan数
    Luogu P3004 [USACO10DEC]宝箱Treasure Chest
  • 原文地址:https://www.cnblogs.com/xingyunshizhe/p/10650228.html
Copyright © 2011-2022 走看看