6

how can I change timezone on MSYS+MinGW for Windows if I have only "date" command installed? There are no "tzconfig" or "tzselect" here.

When I try $date --set="Apr 01 23:08 UTC+04:00" I receive 19:08 GMT+0 result.

This is very important for me because "make" command always gives me errors about files modified in future.

asked Apr 1, 2010 at 19:21
6
  • 1
    Belongs on superuser.com Commented Apr 1, 2010 at 19:36
  • MSYS uses the Windows date/time. If you need to change these, do it via the Windows Control Panel. Commented Apr 1, 2010 at 19:38
  • 2
    NO, MSYS doesn't see Windows settings! Commented Apr 1, 2010 at 19:40
  • @d9K I just changed my Windows time via Control Panel, started a new MSYS bash shell, and ran the date command. The change was reflected in the output of the date command. Commented Apr 1, 2010 at 19:45
  • 1
    @d9k Well, what can I say? I'm not making this up. And where else do you think MSYS is going to get the date/time from? Commented Apr 1, 2010 at 19:50

4 Answers 4

12

I had the same issue. My timezone is CET (GMT+1).

I have fixed this by setting environment variable TZ, like so:

export TZ=CET-1CEST

Before setting the variable I had:

(dos prompt)

c:\>time
Huidige tijd: 17:08:32,40

(msys shell)

$ date
Mon Oct 25 15:08:54 GMT 2010

After setting TZ=CET-1CEST it becomes:

(dos prompt)

c:\>time
Huidige tijd: 17:14:30,80

(msys shell)

$ export TZ=CET-1CEST
$ date
Mon Oct 25 17:15:05 CEST 2010

The fields in this variable are

  • CET: the name of your timezone
  • +/-x: the offset in hours to go from your timezone to GMT (in my example GMT lags one hour on CET)
  • CEST: the name of your timezone with daylight saving time enabled
  • (optionally) +/-y: the offset in hours from your timezone in daylight saving time (DST) to GMT. The default is on hour, so you can skip it.

Note that the first and third field are just used to display in the date string. You can just as well set it to FOO and BAR if you like, it's the second (and optionally fourth) field that do the actual time modification.

The parameter can take even more fields to define when DST starts and ends. If you like to read more about it, see this page.

answered Oct 25, 2010 at 15:24
Sign up to request clarification or add additional context in comments.

Comments

0

This is copy & pasted from my PC. Start a Windows cmd.exe prompt - and then:

d:\Users\NeilB>time
The current time is: 20:59:27.68
Enter the new time: 21:59

Then switch to an MSYS bash shell:

[neilb@GONERIL NeilB]$ date
Thu Apr 1 21:59:31 GMTDT 2010

Notice the time has changed. This also works using Control Panel.

answered Apr 1, 2010 at 20:01

3 Comments

OK, it changes time, but still in other timezone. So when I change it to 0:26 in cmd I get 20:26 in MSYS. When I change time to 0:26 in MSYS I get 4:26 in windows. So I need a method of changing time zone from MSYS console.
@d9K So you want an MSYS bash prompt and Windows to be in different timezones? I don't think that is possible. MSYS is not an operating system and has no concept of its own time, date or timezone.
@anon: the date and time are the system's, but MSYS can decide the timezone and you can even have several MSYS windows in different timezones.
0

I ran into the same timezone problem. My best shot was to use : date --date="4 hours ago" , where -4h is my timezone... It worked for me to time-stamp my stuff but I'm not sure it's gonna be of any help for "make"...

answered Apr 29, 2010 at 2:47

Comments

0

For the record, in addition to the great answer from Geert, Here is what I added to my ~/.bash_profile, living in France :

export TZ=CET-1CEST-2

And it works great.

answered Jun 21, 2011 at 14:30

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.