Skip to main content
Bun supports programmatically setting a default time zone for the lifetime of the bun process. Set the TZ environment variable to a valid time zone identifier.
When running a file with bun, the time zone defaults to your system’s configured local time zone.When running tests with bun test, the time zone is set to UTC to make tests more deterministic.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35bprocess.ts
process.env.TZ = "America/New_York";

You can also set TZ on the command line when running a Bun command.
terminal
TZ=America/New_York bun run dev

Once TZ is set, every Date instance uses that time zone.
https://mintcdn.com/bun-1dd33a4e/JUhaF6Mf68z_zHyy/icons/typescript.svg?fit=max&auto=format&n=JUhaF6Mf68z_zHyy&q=85&s=7ac549adaea8d5487d8fbd58cc3ea35bprocess.ts
new Date().getHours(); // => 18

process.env.TZ = "America/New_York";

new Date().getHours(); // => 21