Advertisement

Lua中时间函数如何使用

阅读量:
复制代码
 时间函数:

    
 local now = os.time()
    
 local curTime = os.date("*t", now)
    
 local curWeek = os.date("%w",now)  --星期天是0
    
 print(curTime.year, curTime.month, curTime.day, curTime.hour, curTime.min, curTime.sec, curWeek)
    
  
    
 --注意区分大小写:
    
 local timeStr = os.date("%Y-%m-%d %H:%M:%S", now)  --2021-09-19 15:32:41
    
 local timeStr = os.date("%Y/%m/%d is %A", now)  --2021/09/19 is Sunday
    
 --%w:星期天为0
    
 local timeStr = os.date("%Y/%m/%d is %w", now)  --2022/03/01 is 2
    
  
    
 @比较两个时间戳,返回相差多少天
    
 function timediff(begin_time,end_time)
    
 	if begin_time 

全部评论 (0)

还没有任何评论哟~