aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/runtime
diff options
context:
space:
mode:
authorGravatar Colin McDonnell <colinmcd94@gmail.com> 2023-08-24 22:28:07 -0700
committerGravatar GitHub <noreply@github.com> 2023-08-24 22:28:07 -0700
commit73b3fb7b0fa7cc786e147ccf1247cd9883ad8e59 (patch)
treecf26d0aad9b0b90904989c07fc344e37c6fe5f2a /docs/guides/runtime
parent2bcbafe7d32c18f611f7c7bd20e4c9d4d92a18ea (diff)
downloadbun-73b3fb7b0fa7cc786e147ccf1247cd9883ad8e59.tar.gz
bun-73b3fb7b0fa7cc786e147ccf1247cd9883ad8e59.tar.zst
bun-73b3fb7b0fa7cc786e147ccf1247cd9883ad8e59.zip
Add guides for test runner (#4308)
Diffstat (limited to 'docs/guides/runtime')
-rw-r--r--docs/guides/runtime/timezone.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/docs/guides/runtime/timezone.md b/docs/guides/runtime/timezone.md
new file mode 100644
index 000000000..528f759fa
--- /dev/null
+++ b/docs/guides/runtime/timezone.md
@@ -0,0 +1,35 @@
+---
+name: Set a time zone in Bun
+---
+
+Bun supports programmatically setting a default time zone for the lifetime of the `bun` process. To do set, set the value of the `TZ` environment variable to a [valid timezone identifier](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones).
+
+{% callout %}
+When running a file with `bun`, the timezone defaults to your system's configured local time zone.
+
+When running tests with `bun test`, the timezone is set to `UTC` to make tests more deterministic.
+{% /callout %}
+
+```ts
+process.env.TZ = "America/New_York";
+```
+
+---
+
+Alternatively, this can be set from the command line when running a Bun command.
+
+```sh
+$ TZ=America/New_York bun run dev
+```
+
+---
+
+Once `TZ` is set, any `Date` instances will have that time zone. By default all dates use your system's configured time zone.
+
+```ts
+new Date().getHours(); // => 18
+
+process.env.TZ = "America/New_York";
+
+new Date().getHours(); // => 21
+```