git commit -m "$(date)"
-> is displaying in UTC, but how to get preferred time zone?
I wanted to get preferred timezone in git commit
.
git commit -m "$(date)"
-> is displaying in UTC, but how to get preferred time zone?
I wanted to get preferred timezone in git commit
.
Strange, considering I always see my commits using my local timezone.
Meaning you do not need to include date
output in the commit message itself.
But you can set the TZ
environment variable, as seen here to benefit from a display using your timezone.
export TZ=CET git show -s --format=%cd --date=iso-local
That will show the date of your last commit. In CET timezone.
date inside the commit message:
git commit -m "$(date -d 'TZ="Australia/Sydney"')"
You can use the Set Timezone GH Action. This action will set the specified timezone for your GH Runner's machine.
For example:
uses: szenius/set-timezone@v1.1
with:
timezoneLinux: "Asia/Singapore"
timezoneMacos: "Asia/Singapore"
timezoneWindows: "Singapore Standard Time"
Under the hood, it uses the timedatectl
(Linux), timezoneMacos
(MacOS), or timezoneWindows
(Windows) tool to set a timezone depending on your job environment.
This Action should be placed before executing the git commit
command and within a single job.