generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Getting the current date

Previous Thread :: Next Thread 
Bloxferatu is not online. Bloxferatu
Joined: 03 Jan 2011
Total Posts: 400
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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image