Help with HTTP service

Hello there is there anything wrong with this?

local http = game:GetService("HttpService")

local js = http:GetAsync("http://worldclockapi.com/api/json/utc/now")

print(js.currentDateTime)

Im trying to get the current Date and Time but it returns Nil
image

I have been searching in the Forum and can’t seem to find the solution, if anyone knows what is wrong with please tell me.

1 Like

Why do you need to use HttpService?

I would use os.time/date, it’s built into roblox.

1 Like

I did try using os.date but i did not know how to get the current time in EST.

I tried couple of scripts in the DevForum but didn’t get what i wanted.

You could subtract 5 hours from the time you get to go from UTC to EST. Check this post out.

2 Likes

I see this was marked as solved already, but for future reference, HttpService:GetAsync() does not return an object, it returns a status code and whatever the body of the request was.

local http = game:GetService("HttpService")

local js = http:GetAsync("http://worldclockapi.com/api/json/utc/now")

print(http:JSONDecode(js).currentDateTime)
4 Likes

Thanks, this will help me for the future as im new to HTTP services.

1 Like

It’s worth noting that this does not account for EDT, meaning the time can be inaccurate when the clocks change. A method I thought about for solving this debacle was to subtract either 4-5 hours from os.time depending on the day of the year it is. The ultimate goal is not to rely on Http requests.