git timezone and timestamp format
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
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:
%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.
Useful tokens:
%adauthor date, format controlled by--date%cdcommitter date, format controlled by--date%aIstrict ISO author date%cIstrict ISO committer date%atauthor Unix epoch%ctcommitter 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:
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.
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.
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.
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.
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.
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
%aIand%cIfor 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
- git tries to delete a directory on checkout
- git undo all uncommitted or unsaved changes
- git undo all uncommitted or unsaved changes
- git, undo all working dir changes including new files
- git undo all working dir changes including new files
- Git undo changes in some files
- Git undo local branch delete
- git update-index --assume-unchanged and git reset
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack 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.