This article mainly introduces the LUA time transformation Several small examples, this article directly gives 3 paragraph example code, needs the friend to be possible to refer to under
1, the time seconds, the conversion of XX days xx xx seconds of the form
The code is as follows:
--The time of the second, the conversion of XX days xx when xx minutes xx seconds of the form
function Converttimeform (second)
Local timeday = Math.floor (second/86400)
Local timehour = Math.fmod (Math.floor (second/3600), 24)
Local Timeminute = Math.fmod (Math.floor (SECOND/60), 60)
Local Timesecond = Math.fmod (second, 60)
Return Timeday, Timehour, Timeminute, Timesecond
End
2, the time seconds, the conversion of XX minutes xx seconds of the form
The code is as follows:
Local function Formattime (time)
Local hour = Math.floor (time/3600);
Local minute = Math.fmod (Math.floor (TIME/60), 60)
Local second = Math.fmod (time, 60)
Local rttime = String.Format ("%s:%s:%s", hour, minute, second)
Return Rttime
End
3,
The code is as follows:
--Convert the number of seconds from 1990.1.1 to date
--endtime Unit Millisecond
Os.date ("%y-%m-%d%h:%m", Math.floor (endtime/1000))