Zsh function to commit in local timezone
I discovered a couple of days ago that my git installation is showing UTC timestamps instead of my local offset (CDT at this moment of the year).
This is the output when executing
+0000 part determines the UTC offset,
+0000 means that we are talking about UTC,
-0500 represents a delay (or negative offset) of five hours with respect to UTC, which is known as CDT.
This behavior of Git doesn’t bother me most of the time, but there’s one use case when I’d like to have local timestamps, which is correctly displaying the last modified date in my website posts.
The easiest way to achieve the desired behavior is to tweak the Git environment variables, since I want to enable both committing with UTC and local timestamps.
Because I’m using zsh, I added the following function in my
source ~/.zshrcor restart the shell.
That’s a shortcut to setting both environment variables each time that I want local timestamps in my commits. For UTC timestamps I commit the usual way.
The function is available in my dotfiles.