Git
timestamps
timezone
version control
datetime format

git timezone and timestamp format

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

Git stores timestamps with timezone offsets for both author and committer metadata. These values influence history readability, release automation, and debugging across distributed teams. Knowing timestamp formats and timezone behavior helps avoid confusion when commits appear out of order.

Core Sections

Author Date and Committer Date

Each commit tracks two separate times:

  • author date, when the change was originally written
  • committer date, when it was committed or rewritten in the current history

View both values explicitly:

bash
git log -1 --pretty='format:author=%aI committer=%cI'

%aI and %cI are strict ISO 8601 formats and are best for machine parsing.

Common Git Date Placeholders

Git provides several placeholders with different readability and precision.

bash
git log -1 --pretty='format:%h %ad %cd %an' --date=iso-strict

Useful tokens:

  • %ad author date, format controlled by --date
  • %cd committer date, format controlled by --date
  • %aI strict ISO author date
  • %cI strict ISO committer date
  • %at author Unix epoch
  • %ct committer Unix epoch

For automation, strict ISO or epoch values are safer than locale-specific formats.

Display Timezones Clearly

By default, git log output can vary by config and locale. Force a predictable display format:

bash
git log --pretty='format:%h %aI %cI %s' -5

Example output includes timezone offsets such as -0500 or +0000. This is essential when debugging events across regions.

Set Dates During Commit Creation

You can set author and committer dates through environment variables.

bash
GIT_AUTHOR_DATE='2026-03-04T09:00:00-0500' \
GIT_COMMITTER_DATE='2026-03-04T09:05:00-0500' \
git commit -m 'Backfill migration script'

Use this carefully. Artificial dates can confuse audit trails if applied without team agreement.

Rewriting History and Timestamp Effects

Commands like rebase or amend can change committer dates while keeping author dates unchanged. Compare both when investigating timeline anomalies.

bash
git log --pretty='format:%h | %an | %aI | %cn | %cI | %s' -10

If commit order looks odd in tools, inspect both fields before assuming data corruption.

Timestamp Formatting for Reports

Release scripts often need stable time output. Use strict ISO with UTC conversion when building external reports.

bash
git log --pretty='format:%H,%aI,%cI,%s' --date=iso-strict > commits.csv

If UTC normalization is required, parse these values in reporting code and convert there. Keep raw git metadata unchanged for traceability.

Configuration Choices

You can set default log date format globally or per repo.

bash
git config --global log.date iso-strict
git config --global format.pretty 'format:%h %aI %s'

These defaults reduce ambiguity during daily work, especially for global teams.

Compare Time Ordering Across Timezones

When debugging distributed incidents, sort by epoch values to avoid visual confusion from different timezone offsets.

bash
git log --pretty='format:%h %at %ct %s' --reverse

Epoch timestamps remove timezone interpretation issues during incident timelines. You can convert to local display format later in dashboards while keeping one canonical ordering source.

Team Policy Recommendation

Document one standard date format for pull request templates and release notes. Consistent formatting eliminates time interpretation arguments during incident response and postmortem analysis.

Common Pitfalls

  • Assuming author date and committer date always match.
  • Using locale-dependent date output in automated parsers.
  • Rewriting history without understanding committer date changes.
  • Comparing timestamps across regions without checking timezone offset.
  • Manually setting fake dates and creating audit confusion.

Summary

  • Git stores both author and committer timestamps with timezone offsets.
  • Prefer %aI and %cI for strict, machine-friendly output.
  • Inspect both dates when history order seems unexpected.
  • Use stable formatting in automation and reporting pipelines.
  • Treat manual date overrides carefully to preserve trust in history.

Related reading
Free course
Beginner
7 lessons
2 hours
Tackling System Design Interview Problems

A short course that equips you with the skills to approach system design interviews methodically.

Start the free course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.