在准备书写时间的时候,在网上查了下面两个函数并进行的打印,得到下面的结果
os.time()
printz(os.time())
>1489974631
os.date()
print(os.date())
>03/20/17 09:50:42
其中
os.time返回的是从1970年x月x日到现在经过的秒数,os.date返回的是按照一定格式输出的日期字符串或table
在os.date中的时间的显示是美式的03/20/17 09:50:42,如果要显示成2017-03-20 09:50:42的话,os.date("%Y-%m-%d %H:%M:%S", curT)
curT 是服务端按一定的格式发过来的
服务端获取时间的格式
strftime(tAddMoneyAndTimer.cTimer, sizeof(tAddMoneyAndTimer.cTimer), "%Y/%m/%d %X ",localtime(&t));
所以我们才以os.date("%Y-%m-%d %H:%M:%S", curT)的格式书写
os.date()在不传入参数的时候打印的是当前网络的时间