temps Unix à Human Readable Date et heure
-
10-10-2019 - |
Question
Im travaillant en lua avec le soutien de la date de telle sorte que quelques façons de convertir unix e milliseconde temps en temps et la date
jj / mm / aaaa hh: mm: ss
J'ai l'heure et le jour, mais l'année et le mois sont difficiles
Merci.
EDIT: All I Need est le jour du mois maintenant je me suis dit les autres parties
EDIT: la première partie du Code NO JOUR DU MOIS et travaille toujours sur l'heure d'été
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
je vais le rendre plus agréable AFER je reçois jour du mois et l'heure d'été
La solution
Pour les personnes qui se demandent ....
Voici comment je l'ai fait:
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
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow