Skip to main content
edited body; edited tags; edited title
Source Link
quack quixote
  • 42.9k
  • 14
  • 108
  • 130

ls in dos promptcmd window gives one hour off time.

I have ls installed on my windows xpWindows XP computer. It came with msysgit. I've had it a while and it turns out I use it quite a lot even in the DOS prompt. More than dir.

ls in dos prompt gives one hour off time.

I have ls installed on my windows xp computer. It came with msysgit. I've had it a while and it turns out I use it quite a lot even in the DOS prompt. More than dir.

ls in cmd window gives one hour off time.

I have ls installed on my Windows XP computer. It came with msysgit. I've had it a while and it turns out I use it quite a lot even in the DOS prompt. More than dir.

more info added after njd's answer.
Source Link
Gauthier
  • 1.2k
  • 2
  • 17
  • 31

EDIT: more info added after njd's answer.

Changing the env variable TZ does have effect. I live in Sweden, where time is CET in winter, CEST in summer. I tested both UTC, CET, and CEST, and reached strange (for me) results:

C:\Program\Git\bin>set TZ=UTC

C:\Program\Git\bin>.\date
Mon Feb 15 12:53:26 GMT 2010

C:\Program\Git\bin>set TZ=CET

C:\Program\Git\bin>.\date
Mon Feb 15 12:53:50 GMT 2010

C:\Program\Git\bin>set TZ=CEST

C:\Program\Git\bin>.\date
Mon Feb 15 12:53:59 GMT 2010

C:\Program\Git\bin>set TZ=CET+1

C:\Program\Git\bin>.\date
Mon Feb 15 11:54:27 CET 2010

C:\Program\Git\bin>set TZ=CET-1

C:\Program\Git\bin>.\date
Mon Feb 15 13:54:35 CET 2010

Setting TZ to CET or CEST has no effect. The date displayed is still GMT. It seems that the string CET alone has no effect. Is it only a string for displaying, and is only taken into account if there is a explicit offset.

C:\Program\Git\bin>set TZ=FOO-1

C:\Program\Git\bin>.\date
Mon Feb 15 14:00:29 FOO 2010

C:\Program\Git\bin>set TZ=BAR-1

C:\Program\Git\bin>.\date
Mon Feb 15 14:00:42 BAR 2010

So it seems.

-1 has the correct effect. But Sweden's time is UTC+1: CET on wikipedia

Is there a mismatch in the convention, -1 in TZ is UTC+1?

If I want to let the OS decide if it's summer or winter as indicated in njd's reply, I can omit the start and end time. I suppose the correct string is TZ=CET-1CEST-2, is that correct?

I am not sure what windows does in summertime. If it updates the clock itself, the string above will not work. If it updates the offset only, then this might work. More insights?


EDIT: more info added after njd's answer.

Changing the env variable TZ does have effect. I live in Sweden, where time is CET in winter, CEST in summer. I tested both UTC, CET, and CEST, and reached strange (for me) results:

C:\Program\Git\bin>set TZ=UTC

C:\Program\Git\bin>.\date
Mon Feb 15 12:53:26 GMT 2010

C:\Program\Git\bin>set TZ=CET

C:\Program\Git\bin>.\date
Mon Feb 15 12:53:50 GMT 2010

C:\Program\Git\bin>set TZ=CEST

C:\Program\Git\bin>.\date
Mon Feb 15 12:53:59 GMT 2010

C:\Program\Git\bin>set TZ=CET+1

C:\Program\Git\bin>.\date
Mon Feb 15 11:54:27 CET 2010

C:\Program\Git\bin>set TZ=CET-1

C:\Program\Git\bin>.\date
Mon Feb 15 13:54:35 CET 2010

Setting TZ to CET or CEST has no effect. The date displayed is still GMT. It seems that the string CET alone has no effect. Is it only a string for displaying, and is only taken into account if there is a explicit offset.

C:\Program\Git\bin>set TZ=FOO-1

C:\Program\Git\bin>.\date
Mon Feb 15 14:00:29 FOO 2010

C:\Program\Git\bin>set TZ=BAR-1

C:\Program\Git\bin>.\date
Mon Feb 15 14:00:42 BAR 2010

So it seems.

-1 has the correct effect. But Sweden's time is UTC+1: CET on wikipedia

Is there a mismatch in the convention, -1 in TZ is UTC+1?

If I want to let the OS decide if it's summer or winter as indicated in njd's reply, I can omit the start and end time. I suppose the correct string is TZ=CET-1CEST-2, is that correct?

I am not sure what windows does in summertime. If it updates the clock itself, the string above will not work. If it updates the offset only, then this might work. More insights?

Source Link
Gauthier
  • 1.2k
  • 2
  • 17
  • 31

ls in dos prompt gives one hour off time.

I have ls installed on my windows xp computer. It came with msysgit. I've had it a while and it turns out I use it quite a lot even in the DOS prompt. More than dir.

The thing is that it gives me time stamps with one hour offset. See the date for gcc.exe, ls says 15:01, dir says 16:01:

C:\MinGW\bin>ls --full-time gcc.exe
-rwxr-xr-x    1 gaf      Administ    90112 Thu Apr 24 15:01:53 2008 gcc.exe

C:\MinGW\bin>dir gcc.exe
 Volymen i enhet C har ingen etikett.
 Volymens serienummer är 644A-83A3

 Innehåll i katalogen C:\MinGW\bin

2008-04-24  16:01            90 112 gcc.exe
               1 fil(er)              90 112 byte
           0 katalog(er)  104 458 203 136 byte ledigt

(sorry for the strange language)

I can tell that it is ls that is doing it wrong, I checked that with newly created files.

It's quite disturbing, any suggestion on how I can solve that?