zoukankan      html  css  js  c++  java
  • lua中的时间函数

    -- 获取当前的格林尼治时间
    print(os.time())


    -- 获取当前时间的字符串表示,形如:11/28/08 10:28:37
    print(os.date())


    -- 获取当前日期的字符串表示,形如:11/28/08
    print(os.date("%x", os.time()))


    -- 获取当前时间的字符串表示,形如:10:28:37
    print(os.date("%X", os.time()))


    -- 获取当前时间的字符串表示,形如:10/10/13 10:28:37
    print(os.date("%c", os.time()))


    -- 获取当前时间的字符串表示,形如:2013-10-10 10:28:37
    print(os.date("%Y-%m-%d %H:%M:%S", os.time()))




    --函数os.clock返回执行该程序CPU花去的时钟秒数
    local x1 = os.clock()
    local s = 0
    for i = 1, 10000000 do
    s = s + i
    end
    local x2 = os.clock()
    print(string.format("elapsed time: %.2f ", x2 - x1))




    local T2009_StartTime = { year=2013, month=2, day=9, hour=0, min=0, sec=0 }
    local T2009_EndTime = { year=2013, month=2, day=17, hour=23, min=59, sec=59 }


    T2009_AvtivityTime = { startTime = os.time(T2009_StartTime), endTime = os.time(T2009_EndTime) }


    print('加载礼包活动成功,活动时间:' .. os.date('%c', T2009_AvtivityTime.startTime) ..
    '~' .. os.date('%c', T2009_AvtivityTime.endTime))




    temp = os.date("*t", os.time())
    print(temp)
    --[[则会产生表
    {year = 1998, month = 9, day = 16, yday = 259, wday = 4,
     hour = 23, min = 48, sec = 10, isdst = false}
    --]]

  • 相关阅读:
    Faster rcnn代码理解(2)
    Faster rcnn代码理解(1)
    BN讲解(转载)
    faster-rcnn
    编程修养
    人才盘点
    Source Insight 技巧总结
    使用DNSSCrypt解决DNS污染问题
    程序员的自我修养 学习笔记(5)
    闯红灯检测原理
  • 原文地址:https://www.cnblogs.com/showonce/p/5929320.html
Copyright © 2011-2022 走看看