Get time and date

Added by iNTERFACEWARE

Using date and time functions with some formatting examples

Source Code
   -- get the current time   
   -- in a custom userdata format
   local tm = os.time()   
   -- as a Unix Epoch time
   local tm = os.ts.time()
   
   -- format a supplied time
   -- in a userdata format
   local tm = os.time{year=1999, month=12, day=01}
   -- hour, min & sec are optional
   local tm = os.time{year=1999, month=12, day=1, hour=22, min=23, sec=24}  
   -- as a Unix Epoch time
   local tm = os.ts.time{year=1999, month=12, day=01}
   -- hour, min & sec are optional
   local tm = os.ts.time{year=1999, month=12, day=1, hour=22, min=23, sec=24}  

      
   -- get the current date
   -- as a string (all 4 return the same)
   local tm = os.date()
   local tm = os.ts.date()   
   local tm = os.date('%c')
   local tm = os.ts.date('%c')
   -- as a table
   local tm = os.date('*t')
   local tm = os.ts.date('*t')
   
   
   -- format a supplied date
   -- as a string (from a userdata format)
   local tm = os.date('%c',os.time{year=1999, month=12, day=1})
   local tm = os.date(_,os.time{year=1999, month=12, day=1})
   -- as a string from a Unix Epoch time
   local tm = os.ts.date('%c',os.ts.time{year=1999, month=12, day=1})
   local tm = os.ts.date(_,os.ts.time{year=1999, month=12, day=1})
   -- as a table
   local tm = os.date('*t',os.time{year=1999, month=12, day=1})
   local tm = os.ts.date('*t',os.ts.time{year=1999, month=12, day=1})
   -- date in mm/dd/yy format
   local tm = os.date('%x',os.time{year=1999, month=12, day=1})
   local tm = os.ts.date('%x',os.ts.time{year=1999, month=12, day=1})
   -- 24 hour time
   local tm = os.date('%X',os.time{year=1999, month=12, day=1, hour=22, min=23, sec=24})
   local tm = os.ts.date('%X',os.ts.time{year=1999, month=12, day=1, hour=22, min=23, sec=24})
   -- date and time
   local tm = os.date('%x %X',os.time{year=1999, month=12, day=1, hour=22, min=23, sec=24})
   local tm = os.ts.date('%x %X',os.ts.time{year=1999, month=12, day=1, hour=22, min=23, sec=24})