Timezone setting in Linux

10,170

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.

Share:
10,170

Related videos on Youtube

Admin
Author by

Admin

Updated on September 18, 2022

Comments

  • Admin
    Admin almost 2 years

    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
    
    • Admin
      Admin over 10 years
      The date shows GMT+6, the same zone as the zone you copied to /etc/localtime.
    • Admin
      Admin over 10 years
      @mockinterface: You are right but why date command is showing time less then UTC time?
    • Admin
      Admin over 10 years
      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.
    • Alfe
      Alfe over 10 years
      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.
    • grebneke
      grebneke over 10 years
      Some kind of 12/24 hrs problem? 17 == 05 PM ?
    • grebneke
      grebneke over 10 years
      BTW, this is not a programming question, is it? Migrate to ServerFault or Unix&Linux?
    • Alfe
      Alfe over 10 years
      Maybe it is. Depends on the answer.
    • Alfe
      Alfe over 10 years
      Try date +"%R p %Z" to see if it's an AM/PM issue and which time zone the date command assumes.
    • slm
      slm over 10 years
      This Q was cross posted on U&L as well: unix.stackexchange.com/questions/110522/…
  • Admin
    Admin over 10 years
    Thanks for your answer but I'm using GMT+ format in my embedded system and found this type of behavior
  • Matt Johnson-Pint
    Matt Johnson-Pint over 10 years
    I'm not sure what you're getting at. You asked why it was reversed, and this is why.
  • Matt Johnson-Pint
    Matt Johnson-Pint over 10 years
    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.