0

I always thought Linux systems used /etc/timezone for the timezone, but:

$ cat /etc/timezone 
Etc/UTC
$ date
Tue May 28 12:34:01 PM PDT 2024

Here, the /etc/timezone is UTC but date is reporting in PDT.

How is date determining the timezone?

This is Ubuntu 22.04, if it matters.

2
  • Does this answer your question? How to change the user timezone? Commented May 28, 2024 at 19:52
  • Not that you said it is, but I don't think this is a duplicate of that necessarily, since this is mostly about the difference between /etc/timezone and /etc/localtime. Commented May 28, 2024 at 20:35

1 Answer 1

4

/etc/timezone is used by some applications (mostly Java applications), but /etc/localtime is typically the authoritative source of timezone information for a system. /etc/timezone is usually a symlink to a file in the /usr/share/zoneinfo directory which contains the time zone data, and it is used by most libc implementations internally when no TZ environment variable is set. systemd also adds timedatectl to control it, which you should have on Ubuntu.

In your specific case, although /etc/timezone shows Etc/UTC, the output of the date command shows the time in PDT. This discrepancy usually indicates that the /etc/localtime file is set to a different time zone than what is indicated in /etc/timezone.

To verify and resolve this discrepancy:

  1. Check ls -l /etc/localtime, which probably shows PDT or a similar timezone;
  2. Update the timezone using sudo dpkg-reconfigure tzdata, or sudo timedatectl set-timezone Etc/UTC.
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.