|
| 25 Jun 2015 08:10 PM |
| Is there a way for me to get the current date, as in, mm/dd/yy in string format? I'd use os.date, but it seems to not be a part of the RBLX Lua API. |
|
|
| Report Abuse |
|
Ictis
|
  |
| Joined: 01 Sep 2011 |
| Total Posts: 1216 |
|
|
| 25 Jun 2015 08:31 PM |
| os.time() will work but you'll have to do some math to get the current date. |
|
|
| Report Abuse |
|
cxcharlie
|
  |
| Joined: 26 Aug 2009 |
| Total Posts: 1414 |
|
|
| 25 Jun 2015 09:26 PM |
I didn't make this
local weekds={"Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"} local months={"January","February","March","April","May","June","July","August","September","October","November","December"} local daysny={31,28,31,30,31,30,31,31,30,31,30,31} local daysly={31,29,31,30,31,30,31,31,30,31,30,31} local secs_day=86400
local function th(n) local f=n%10 local g=n%100 if f==1 and g~=11 then return n.."st" elseif f==2 and g~=12 then return n.."nd" elseif f==3 and g~=13 then return n.."rd" else return n.."th" end end
local function tod(pdy,showsec) local hr,phr=modf(pdy*24) local mn,pmn=modf(phr*60) local sec,ms=modf(pmn*60) local hrmn=format("%d:%02i",(hr-1)%12+1,mn)..(hr<12 and "AM" or "PM") if showsec then return hrmn..format("/%02is",sec) else return hrmn end end
local function Date(Unix,abbr) -- gets the date from tick time local loldays=Unix/secs_day local days=loldays local ycount=1970 local mcount=1 repeat if ycount%400==0 or ycount%100~=0 and ycount%4==0 then if days>=daysly[mcount] then days=days-daysly[mcount] else break end elseif days>=daysny[mcount] then days=days-daysny[mcount] else break end mcount=mcount+1 if mcount>#months then mcount=1 ycount=ycount+1 end until ycount>1e4 --just in case local d,t=modf(days) return concat({tod(t,true),weekds[floor(loldays+3)%7+1],months[mcount],th(d+1),ycount}," ") end
print(Date(tick()))
|
|
|
| Report Abuse |
|