timeRange()

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

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

Used in under 1% of the real PAC files in the PAC file statistics.

Local 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

EngineBehaviourSource
chromiumWraps 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
services/proxy_resolver/pac_js_library.h@cb6eb0e7
firefoxSame as Chromium.lab, verified 2026-10-11
netwerk/base/ascii_pac_utils.js@3f73c528
pacparserNo wrap-around ranges.lab, verified 2026-10-11
src/pac_utils.h@v1.5.3
winhttpAlways false, whatever the arguments (10 forms tested, including timeRange(0, 24) and the current hour).lab, verified 2026-10-11
Windows 11 25H2

Availability

Derived from each engine's vendored helper library plus its native bindings (see engines).
Functionchromium
<=51
chromium
>=52
firefox
all
pacparser
<=1.4.6
pacparser
>=1.5.1
winhttp
11-25H2
wininet
11-25H2
reference
all
timeRangeyesyesyesyesyesyesyesyes

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.

Last updated: