# This file is automatically generated. Please don't edit it manually. # To submit a bug report on the content, see # https://devforum.roblox.com/c/bug-reports/documentation-issues/72 name: os type: library summary: | This library provides functions related to time and date. description: | This library currently serves the purpose of providing information about the system time under the UTC format. It has been heavily sandboxed from the standard Lua `Library.os` library and does not allow you to perform any system-altering operations. tags: [] code_samples: [] properties: [] functions: - name: os.clock summary: | Returns elapsed time in seconds since an arbitrary baseline with sub-microsecond precision. description: | Returns elapsed time in seconds since an arbitrary baseline with sub-microsecond precision. This function is useful for comparing durations between two events that occur on the same computer, and is the best option for benchmarking. Unlike with functions such as `Library.os.time()` or `Datatype.DateTime.now()`, adjustments to the system clock (such as by the user or [NTP](https://en.wikipedia.org/wiki/Network_Time_Protocol)) do not cause time to jump forwards or backwards. ```lua -- Record the initial time: local startTime = os.clock() -- Do something you want to measure the performance of: local a, b = 0, 1 for _ = 1, 5000000 do a, b = b, a end -- Measure amount of time this took: local deltaTime = os.clock() - startTime print("Elapsed time: " .. deltaTime) --> Elapsed time: 0.044425600033719 (actual number may vary) ``` parameters: [] returns: - type: double summary: '' tags: [] code_samples: [] deprecation_message: '' - name: os.date summary: | Formats the given string with date/time information based on the given time. description: | Formats the given `formatString` with date/time information based on the given time, or if not provided, the value returned by `Library.os.time()`. This function should be avoided in new work. Instead, use the `Datatype.DateTime` API, which supports localized formatting. The following specifiers (based on the C function strftime) are supported:
| Specifier | Meaning | Example† |
|---|---|---|
%a |
Abbreviated weekday name * | Mon |
%A |
Full weekday name * | Monday |
%b |
Abbreviated month name * | Feb |
%B |
Full month name * | February |
%c |
Date and time * | Mon Feb 12 14:14:35 2024 |
%d |
Day of the month | 12 |
%H |
Hour, using 24-hour clock | 14 |
%I |
Hour, using 12-hour clock | 02 |
%j |
Day of year | 043 |
%m |
Month | 02 |
%M |
Minute | 14 |
%p |
Either "AM" or "PM" | PM |
%S |
Second | 35 |
%U |
Week number (first Sunday as the first day of week one) | 06 |
%w |
Weekday | 1 |
%W |
Week number (first Monday as the first day of week one) | 07 |
%x |
Date * | 02/12/24 |
%X |
Time * | 14:14:35 |
%y |
Two-digit year | 24 |
%Y |
Full year | 2024 |
%z |
ISO 8601 offset from UTC in timezone (1 minute = 1, 1 hour = 100) | -0800 |
%Z |
Timezone name or abbreviation * | PST |
%% |
The % character | % |
| Field | Type | Description |
|---|---|---|
| year | int | An integer that describes the current year of the Current Era (ex. 2017) |
| month | int | An integer between 1 and 12 (starting from January) that describes the current month. |
| wday | int | An integer between 1 and 7 (starting from Sunday) that describes the current week day. |
| yday | int | An integer between 1 and 366 describing how many days we are into the year. There can be 366 days if it is a leap year. |
| day | int | An integer between 1 and 31 describing the current day of the month. |
| hour | int | An integer between 1 and 24 describing the current hour of the day. |
| min | int | An integer between 0 and 59 describing the current minute of the hour. |
| sec | int | An integer between 0 and 60 describing the current second of the hour. (60 because the function is described to indicate leap seconds, but in practice it probably doesn't). |
| isdst | bool | A boolean describing if daylight savings time is currently active. |