5

I'm setting timezone GMT+6 on my Linux machine by copying the zoneinfo file to /etc/localtime, but the date command is showing the time UTCtime-6. What is the reason for this behaviour?

I'm assuming the date command should display UTCtime+6 time. Here are steps I'm following:

date
Wed Jan 22 17:29:01 IST 2014

date -u
Wed Jan 22 11:59:01 UTC 2014

cp /usr/share/zoneinfo/Etc/GMT+6 /etc/localtime

date
Wed Jan 22 05:59:21 GMT+6 2014

date -u
Wed Jan 22 11:59:01 UTC 2014
9
  • The date shows GMT+6, the same zone as the zone you copied to /etc/localtime.
    – mockinterface
    Commented Jan 22, 2014 at 12:13
  • @mockinterface: You are right but why date command is showing time less then UTC time?
    – Rahul R Dhobi
    Commented Jan 22, 2014 at 12:17
  • I think you need to clarify your question. It has the entire set of IST/GMT+6/UTC-6/UTC+6 time zones mentioned plus the two date commands that you refer to as "a date command" - please be exact.
    – mockinterface
    Commented Jan 22, 2014 at 12:27
  • I think it's clear enough. OP has India standard time set, and it's 17:29 in India which means it's 11:59 UTC. then OP changes just the time zone by that cp command; the UTC isn't affected (as we can see), but the localized time now is 5:59 GMT+6 although it should be 17:59 GMT+6.
    – Alfe
    Commented Jan 22, 2014 at 13:30
  • 1
    This Q was cross posted on U&L as well: unix.stackexchange.com/questions/110522/…
    – slm
    Commented Jan 23, 2014 at 7:43

1 Answer 1

12

Zones like Etc/GMT+6 are intentionally reversed for backwards compatibility with POSIX standards. See the comments on Wikipedia, and in this file from the tzdb.

You should almost never need to use these zones. Instead you should be using a fully named time zone like America/New_York or Europe/London or whatever is appropriate for your location. Refer to the List of tz database time zones on Wikipedia.

3
  • Thanks for your answer but I'm using GMT+ format in my embedded system and found this type of behavior
    – Rahul R Dhobi
    Commented Jan 23, 2014 at 5:44
  • I'm not sure what you're getting at. You asked why it was reversed, and this is why. Commented Jan 23, 2014 at 5:51
  • 6
    A time zone is not the same thing as a time zone offset. You aren't just setting +6, you're setting Etc/GMT+6 which is a very specific entry in the zoneinfo data which means "6 hours West of GMT", which in common usage is -6. If you really want +6 then you should set a zone like Etc/GMT-6, or you can use a named zone that has a +6 offset. See also the timezone tag wiki. Commented Jan 23, 2014 at 5:51

You must log in to answer this question.