timeRange()
True if the current time is within the given hour/minute/second range.
timeRange(hour | hour, min | hour, min, sec ... [, "GMT"]) → booleanLocal time unless “GMT” is passed. The checker evaluates time functions at a fixed “now” you can set, so results are reproducible.
Example
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 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 and pick the Windows (WinHTTP) profile to see the Windows answer.Check how your own file behaves with the PAC file tester: switch the engine profile between Chromium, Firefox, pacparser and Windows and compare the trace. All engine differences are collected in pactester vs Chrome and Firefox.
Engine notes
| Engine | Behaviour | Source |
|---|---|---|
| chromium | Wraps around midnight only in the form with minutes, e.g. timeRange(22, 0, 6, 0); timeRange(22, 6) is never true. | lab, verified 2026-10-11 |
| firefox | Same as Chromium. | lab, verified 2026-10-11 |
| pacparser | No wrap-around ranges. | lab, verified 2026-10-11 |
| winhttp | Always false, whatever the arguments (10 forms tested, including timeRange(0, 24) and the current hour). | lab, verified 2026-10-11 |
Availability
| Function | chromium | chromium | firefox | pacparser | pacparser | winhttp | wininet | reference |
|---|---|---|---|---|---|---|---|---|
timeRange | yes | yes | yes | yes | yes | yes | yes | yes |
Related rules
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.