How to get days passed os time for daily login rewards

you know how you get get seconds passed since 1 January 1970 using

print(os.time())

how do i get the number of days?
i know os.date("*t")["yday"] will print the day of the year, today, dec 16 being 350 but it just gives it for this year and there are also leap years so is there a way to just get days passed like you can get seconds passed. sorry if this is a dumb question

1 Like
os.date("%j") -- Day of the Year (In Numbers)
--------------------------------------------------------------------------------
print(os.date("%j").."/365") -- As if Writing this: "350/365"

os Documentation

1 Like

i mean in the same format that the seconds for os time is in. read the first line of my post

Not sure if this would work:

print(math.floor(os.time()365/24))

(maybe)

1 Like

I’m not sure if this is what you’re asking for, but here:

print(math.floor(os.time() / 86400))
-- Or
print(math.floor(os.time() / 60 ^ 2 / 24))

Got the formula from just converting it one unit above .

2 Likes

Try something like this.

-- Lets put a starting number to keep track of the days the player has been on
local days_on = 0

-- Loops this script forever
while true do
	-- lets increase the value of everyday the player has been on by 1
	days_on = days_on + 1

	-- now lets print the days the player has been on
	print("You have been on for " .. days_on .. " days.")

	-- Every 24 hours, log a day depending on whether the player joined (86400 seconds)
	os.execute("sleep 86400")
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.