Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/lua/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/vue.js/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lua Unix时间到人类可读的日期和时间_Lua_Roblox_Unix Timestamp - Fatal编程技术网

Lua Unix时间到人类可读的日期和时间

Lua Unix时间到人类可读的日期和时间,lua,roblox,unix-timestamp,Lua,Roblox,Unix Timestamp,我在lua工作,没有过时的支持,那么有什么方法可以将unix毫秒时间转换为时间和日期呢 年月日hh:mm:ss 我有时间和日子,但年复一年,月复一年都很艰难 谢谢 编辑:我只需要一个月的某一天,现在我知道了其他部分 编辑:代码的第一部分没有月日,仍在DST上工作 TIMEZONE=-5 DAYLIGHTSAVING=0--NOT DONE while true do t=tick() y=math.floor(1970+ t /31556926) ds=((1970+t/3

我在lua工作,没有过时的支持,那么有什么方法可以将unix毫秒时间转换为时间和日期呢

年月日hh:mm:ss

我有时间和日子,但年复一年,月复一年都很艰难

谢谢

编辑:我只需要一个月的某一天,现在我知道了其他部分

编辑:代码的第一部分没有月日,仍在DST上工作


 TIMEZONE=-5
 DAYLIGHTSAVING=0--NOT DONE

 while true do
  t=tick()
  y=math.floor(1970+ t /31556926)
  ds=((1970+t/31556926)-y)*31556926
  m=math.floor(ds/2629743)+1
  d=math.floor(ds/86400)+1
  md=0--NOT DONE
  wd=d%7+6
  print(md,wd)
  h=math.floor(math.fmod(t,60*60*24)/3600) + 5 + (TIMEZONE) + (DAYLIGHTSAVING)
  mn= math.floor(math.fmod(t,60*60*24)/60 - 60*h)
  s= math.floor(math.fmod(math.fmod(t,60*60*24),60))
  print(m,d,y)
  print(h,mn,s)
  wait(1)
 end

当我得到月日和DST后,我会把它做得更好,因为我想知道

我是这样做的:


TIMEZONE=-5
DST=0

dm={31,28,31,30,31,30,31,31,30,31,30,31}

while true do
t=tick()
y=math.floor(1970+ t /31556926)
ds=((1970+t/31556926)-y)*31556926
m=math.floor(ds/2629743)+1
d=math.floor(ds/86400)+1
md=math.floor(((ds/2629743+1)-m)*dm[m])+1
wd=d%7+6
if(m11)then DST=0 else DST=1 end
if(m==3)then if(md>=14)then DST=1 else DST=0 end end
if(m==11)then if(md>=7)then DST=0 else DST=1 end end
h=math.floor(math.fmod(t,60*60*24)/3600) + 5 + (TIMEZONE) + (DST)
mn= math.floor(math.fmod(t,60*60*24)/60 - 60*(h-DST))
s= math.floor(math.fmod(math.fmod(t,60*60*24),60))
wait(1)
end

如果你能告诉我你是怎么做的,那就太好了。可能会帮助未来的谷歌人!这是在roblox游戏上运行的,因此没有OS.date(),因为没有全局OSuse%操作符,它比使用math.fmod更快。