lua 时间戳和时间互转【简记】

1、获取时间戳 

(1)、os.time() --当前时间戳 

(2)、 os.time({day=5, month=9, year=2018, hour=12, min=59, sec=59})  --指定时间的时间戳

2、获取指定格式时间

(1)、时间格式 yyyyMMddHHmmss:os.date("%Y%m%d%H%M%S", os.time())   --20180905193023

(2)、时间格式 yyyy-MM-dd HH:mm:ss:os.date("%Y-%m-%d %H:%M:%S", os.time())  --2018-09-05 19:30:23

猜你喜欢

转载自www.cnblogs.com/SeeYouBug/p/9594025.html