# timeRange()

Source: https://findproxyforurl.net/functions/timerange/ · last updated 2026-10-11

`timeRange(hour | hour, min | hour, min, sec ... [, "GMT"])` → boolean

True if the current time is within the given hour/minute/second range.

Local time unless "GMT" is passed. The checker evaluates time functions at a fixed "now" you can set, so results are reproducible.

## Example

```js
if (timeRange(8, 18)) {
  return "PROXY proxy.corp.example:8080";
}
```

## timeRange(22, 6) is never true, and night ranges differ between pactester and the browsers

With two hours, `timeRange(22, 6)` does not wrap around midnight in any engine, so a night rule
written this way never matches. The form with minutes, `timeRange(22, 0, 6, 0)`, wraps in
Chrome, Edge and Firefox but not in pactester (pacparser). `timeRange(22, 23) || timeRange(0, 5)`
works the same in Chrome, Edge, Firefox and pactester. The [PAC file tester](https://findproxyforurl.net/check/) flags both cases.

## timeRange is never true on Windows

In Windows (WinHTTP) `timeRange` returned false for every argument form tried, even
`timeRange(0, 24)` and the current hour. Office-hours rules in a PAC file therefore never apply
to Windows programs. Make time-dependent decisions on the proxy instead. Paste your file into the [PAC file tester](https://findproxyforurl.net/check/) and pick the Windows (WinHTTP) profile to see the Windows answer.


## Engine notes

- chromium: Wraps around midnight only in the form with minutes, e.g. timeRange(22, 0, 6, 0); timeRange(22, 6) is never true. (source: lab, verified 2026-10-11)
- firefox: Same as Chromium. (source: lab, verified 2026-10-11)
- pacparser: No wrap-around ranges. (source: lab, verified 2026-10-11)
- winhttp: Always false, whatever the arguments (10 forms tested, including timeRange(0, 24) and the current hour). (source: lab, verified 2026-10-11)

## Frequently asked questions

### How do I write a timeRange that crosses midnight?

Use two ranges, timeRange(22, 23) || timeRange(0, 5). timeRange(22, 6) is never true in any engine, and timeRange(22, 0, 6, 0) wraps in Chrome, Edge and Firefox but not in pactester. On Windows (WinHTTP) timeRange is never true at all, so a night rule should live on the proxy.

