Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the correct local time zone in git bash?

I am using git-bash on a Windows system.

The Windows clock shows local time, but inside git-bash everything is in GMT time:

$ date
Mon Mar 31 16:08:57 GMT 2014

Also setting TZ will not change things:

$ TZ="Europe/Berlin" date
Mon Mar 31 16:09:01 GMT 2014

Similarly all times it git log are GMT only.

Is there a way to set the correct timezone in git-bash?

like image 203
michas Avatar asked Mar 31 '14 16:03

michas


People also ask

How do I change the timezone in GitHub?

Run date +%z to check your system's configuration. Perhaps Git is using the correct time zone but GitHub is displaying the time using the wrong time zone. After you create a commit, run git show and check the offset.


2 Answers

On Windows the TZ variable seems to work differently.

To get the German timezone you have to write:

TZ=GST-1GDT date

If you set it to some "invalid" value like "Europe/Berlin" it will default to GMT. The same seems to happen on my system when TZ is not set at all.

With the above setting I get Thu Apr 17 16:23:23 GDT 2014 which is not exactly the same as Thu Apr 17 16:23:23 CEST 2014, but at least the time looks right.

like image 176
michas Avatar answered Sep 29 '22 07:09

michas


Same problem here in my script. Windows was showing 15:47 and the "date" command in gitbash was answering 13:47.

export TZ="CEST-2" 

This fixed the problem for me. I wanted Paris time.

like image 37
Maxime Beugnet Avatar answered Sep 29 '22 09:09

Maxime Beugnet