# Date and Time

These global variables provide information about the current date and time.

## Basic Time Variables

| Variable | Type   | Description                                |
| -------- | ------ | ------------------------------------------ |
| `second` | String | The current second (00-59)                 |
| `minute` | String | The current minute (00-59)                 |
| `hour`   | String | The current hour in 24-hour format (00-23) |

## Date Variables

| Variable       | Type   | Description                                             |
| -------------- | ------ | ------------------------------------------------------- |
| `day`          | String | The current day of the week (e.g., "Monday", "Tuesday") |
| `day_number`   | Number | The current day of the month (1-31)                     |
| `month`        | String | The current month name (e.g., "January", "February")    |
| `month_number` | Number | The current month as a number (1-12)                    |
| `year`         | Number | The current year (e.g., 2025)                           |

## Timestamps

| Variable      | Type   | Description                                    |
| ------------- | ------ | ---------------------------------------------- |
| `timestamp`   | Number | A wrapper for JavaScript's `Date.now()`        |
| `performance` | Number | A wrapper for JavaScript's `performance.now()` |

## Timezone Information

| Variable                | Type    | Description                                      |
| ----------------------- | ------- | ------------------------------------------------ |
| `timezone`              | String  | The current timezone (e.g., "UTC+1")             |
| `time.offset`           | Number  | The current timezone offset in milliseconds      |
| `time.daylight_savings` | Boolean | Whether daylight saving time is currently active |

## User Time Preferences

| Variable                       | Type    | Description                                        |
| ------------------------------ | ------- | -------------------------------------------------- |
| `user.timeformat.hours`        | String  | The user's preferred time display ("12h" or "24h") |
| `user.timeformat.show_seconds` | Boolean | Whether clocks should specify down to the second   |

## Constants for Day and Month Names

| Variable | Type  | Description                                        |
| -------- | ----- | -------------------------------------------------- |
| `days`   | Array | Array of day names \["Monday", "Tuesday", ...]     |
| `months` | Array | Array of month names \["January", "February", ...] |

## Examples

```javascript
// Display current time
log "Current time: " ++ hour ++ ":" ++ minute ++ ":" ++ second

// Display current date
log "Today is " + day + ", " + month + " " + day_number + ", " + year

// Format date with conditional suffix
suffix = "th"
if day_number % 10 == 1 and day_number != 11 (
  suffix = "st"
)
if day_number % 10 == 2 and day_number != 12 (
  suffix = "nd"
)
if day_number % 10 == 3 and day_number != 13 (
  suffix = "rd"
)
log "Today is the " + day_number + suffix + " of " + month

// Use the arrays to find the day of week by index
tomorrow_index = (days.index(day) + 1) % 7
log "Tomorrow is " ++ days[tomorrow_index]
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://osl.mistium.com/global-variables/date-time.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
