claude-code - 💡(How to fix) Fix TZ env var ignored in Windows Bash — date returns UTC instead of local time [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#50753Fetched 2026-04-20 12:13:59
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Fix Action

Workaround

Use PowerShell instead:

powershell.exe -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'"

Code Example

TZ=Asia/Tokyo date +"%Y-%m-%d %H:%M:%S"
# Returns: 2026-04-19 13:39:49UTC (wrong)

---

Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
# Returns: 2026-04-19 22:40:28JST (correct)

---

powershell.exe -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'"
RAW_BUFFERClick to expand / collapse

Problem

When running TZ=Asia/Tokyo date +%Y-%m-%d\ %H:%M:%S in Windows Bash (Git Bash / MSYS2), the TZ environment variable is silently ignored and UTC time is returned instead of the specified timezone.

Steps to Reproduce

On Windows with Git Bash:

TZ=Asia/Tokyo date +"%Y-%m-%d %H:%M:%S"
# Returns: 2026-04-19 13:39:49  ← UTC (wrong)
Get-Date -Format 'yyyy-MM-dd HH:mm:ss'
# Returns: 2026-04-19 22:40:28  ← JST (correct)

Expected Behavior

TZ=Asia/Tokyo date should return JST (UTC+9).

Actual Behavior

Returns UTC regardless of TZ setting. The offset is exactly 9 hours, confirming TZ is completely ignored.

Impact

Claude Code's global rules recommend using TZ=Asia/Tokyo date +%Y-%m-%d for JST-based timestamps. This guidance produces incorrect (UTC) results on Windows, causing 9-hour date/time errors in logs, filenames, and other time-sensitive operations.

Workaround

Use PowerShell instead:

powershell.exe -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'"

Environment

  • OS: Windows 11 Pro
  • Shell: Git Bash (MSYS2-based)
  • Claude Code version: (latest)

extent analysis

TL;DR

The issue can be worked around by using PowerShell's Get-Date command instead of the date command in Git Bash.

Guidance

  • The TZ environment variable is not being respected by the date command in Git Bash on Windows, causing it to return UTC time instead of the specified timezone.
  • To verify the issue, compare the output of TZ=Asia/Tokyo date +"%Y-%m-%d %H:%M:%S" in Git Bash with the output of Get-Date -Format 'yyyy-MM-dd HH:mm:ss' in PowerShell.
  • As a workaround, use the PowerShell command powershell.exe -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'" to get the correct JST timestamp.
  • Consider updating the global rules to use the PowerShell command for generating timestamps on Windows systems.

Example

# Workaround using PowerShell
powershell.exe -Command "Get-Date -Format 'yyyy-MM-dd HH:mm:ss'"

Notes

This issue appears to be specific to Git Bash on Windows and may not affect other platforms. The workaround using PowerShell should provide the correct timestamp, but it may require adjustments to existing scripts or workflows.

Recommendation

Apply workaround: using PowerShell's Get-Date command is a reliable way to get the correct JST timestamp on Windows systems, and it avoids the issue with the TZ environment variable being ignored by the date command in Git Bash.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING