Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
2

How do get the REAL date? It looks simple.

Asked by 7 years ago

I am trying to make it so if it is Friday there will be special deal's in the shop. I have looked through tons of questions and only found super complex answers. I found on the wiki that when called with a data table it should return a table or something? :P I am new with tables... But anyway it looks like it should be pretty easy to get the month, day, hour, year, etc. As said I am new with table so could someone help explain this?

2 answers

Log in to vote
5
Answered by
evaera 8028 Trusted Badge of Merit Snack Break Game Jam Winner Moderation Voter Administrator Community Moderator Super Administrator
7 years ago

That API refers to passing in dates, not getting them back. Roblox doesn't provide a way to get real dates back out as of right now. (This would be os.date in real Lua.)

Despite this, it's still possible, albeit challenging, to get the real date by mathematical calculation on the Unix epoch.

For a quick answer, you can use the following code which will print the current day (e.g. Friday) using a module written by BlueTaslem.

local Date = require(271818993)

print(Date():format( "Week" )) --> Friday

For further reading, see:

0
Computing day-of-the-week is literally the easier operation and I had a typo in it. I'm not sure how that got past me when I tested. The module is updated to give the correct day-of-week now. BlueTaslem 18071 — 7y
0
You might also be able to use HttpService and get the date from an API on the Internet. JasonTheOwner 391 — 7y
0
ok User#15461 0 — 7y
0
Thanks so much!! User#15461 0 — 7y
Ad
Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Enable HTTPService and use this:

local hs = game:GetService("HttpService")


                local rawdata = hs:GetAsync("https://www.checkiday.com/", true)



                if(type(rawdata)=='string') then
                --  print(rawdata)
                local result=   rawdata:match('\<meta name="description" content="(.+)- Today')
                print("today is: "..result)
end

Answer this question