Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this New Years Timer printing 1970 and not 2019?

I'm making a New Year Countdown timer but my whole script is completely off. When I try to print this code it prints out the year as 1970 and not 2019 and I have no clue why this is happening.

local new_years_date = os.time({
	year = 2019;
	month = 1;
	day = 1;
	hour = 0;
	minute = 0;
	sec = 0;
})



local diffTime = os.difftime(new_years_date, os.time())
local tab = os.date('!*t', diffTime)

for k, v in pairs(tab) do
	print(k, v)
end

OUTPUT: (look at the year)

hour 10 min 17 wday 7 day 3 month 1 year 1970 sec 44 yday 3

1 comment

0

I answered this question

1 answer

You put

local diffTime = os.difftime(new_years_date, os.time())

when you don't need to because new_years_date is already os.time . So here's the working script that prints the correct dates you want it to.

local new_years_date = os.time({
    year = 2019;
    month = 1;
    day = 1;
    hour = 0;
    minute = 0;
    sec = 0
})



local diffTime = os.difftime(new_years_date)
local tab = os.date('!*t', diffTime)

for k, v in pairs(tab) do
    print(k, v)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.