Documentation for os.time does not show dictionary parameter

https://developer.roblox.com/api-reference/lua-docs/os

os.time supports a dictionary parameter, which can be used to specify a specific date. os.time will return the number of seconds since the UNIX Epoch to the date using the entries in the dictionary, or it will use the time when it was called if one isn’t specified. The date format is often gotten using os.date.

The date dictionary requires the day, month and year keys. Any other keys modify the end time. For example, specifying hours and minutes will push the date forward a bit from 00:00 and change the number of seconds retrieved.

os.time(os.date("!*t"))
-- Returns the number of seconds since the UNIX Epoch to the date

As shown on the os library page, os.time is written as though it does not accept any parameters.

This is somewhat of an oversight and for those who didn’t know, a gap in knowledge. I didn’t actually learn about this until yesterday myself.

6 Likes

Thought to bring this one back up since more developers are beginning to make use of the os library and an issue with the page was recently fixed. I think it would be valuable to list two versions of os.time: one without the dictionary parameter and one with, to show the functional difference when passing a date table.

1 Like

Heya. 7 months later and, seeing that a lot of developers are starting to integrate os-based features into their games (rewards systems for logging in after a few hours, subscription services, live markets, so on), it would be nice to have this information on hand. The information is still missing and there might be someone out there with a use case for finding out the seconds that’ll be elapsed at a specific date.

Like ColorSequence, it would be nice to add a second box under os.time() that shows what would happen if a date table was passed. Adding it to the current box might confuse developers in thinking that a date table is required to be passed as a parameter. A second box would also allow for expanding on what would happen should a date table be passed.

1 Like

I’ve updated the function description to describe the optional table parameter. Thank you for bumping this!

2 Likes

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