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.
Related videos on Youtube
![Admin](/assets/logo_square_200-5d0d61d6853298bd2a4fe063103715b4daf2819fc21225efa21dfb93e61952ea.png)
Author by
Admin
Updated on September 18, 2022Comments
-
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 over 10 yearsThe date shows GMT+6, the same zone as the zone you copied to /etc/localtime.
-
Admin over 10 years@mockinterface: You are right but why date command is showing time less then UTC time?
-
Admin over 10 yearsI 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 over 10 yearsI 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 over 10 yearsSome kind of 12/24 hrs problem?
17 == 05 PM
? -
grebneke over 10 yearsBTW, this is not a programming question, is it? Migrate to ServerFault or Unix&Linux?
-
Alfe over 10 yearsMaybe it is. Depends on the answer.
-
Alfe over 10 yearsTry
date +"%R p %Z"
to see if it's an AM/PM issue and which time zone the date command assumes. -
slm over 10 yearsThis Q was cross posted on U&L as well: unix.stackexchange.com/questions/110522/…
-
-
Admin over 10 yearsThanks for your answer but I'm using GMT+ format in my embedded system and found this type of behavior
-
Matt Johnson-Pint over 10 yearsI'm not sure what you're getting at. You asked why it was reversed, and this is why.
-
Matt Johnson-Pint over 10 yearsA time zone is not the same thing as a time zone offset. You aren't just setting
+6
, you're settingEtc/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 likeEtc/GMT-6
, or you can use a named zone that has a +6 offset. See also the timezone tag wiki.