127

How can I display the current time configuration, like the time zone, in Ubuntu?

  • What does the CentOS output for cat /etc/sysconfig/clock look like ? – belacqua Feb 22 '11 at 17:25
  • like this [root@SUPA9611 ~]# cat /etc/sysconfig/clock ZONE="Europe/Amsterdam" UTC=true ARC=false – usef_ksa Feb 22 '11 at 18:24
142

I don't know of a single file, but this may give you the info needed:

cat /etc/timezone
grep UTC /etc/default/rcS
date
# hardware clock
sudo hwclock --show
| improve this answer | |
  • I didn't spot the hwclock bit at first - but that was actually what I was looking for – icc97 Jan 7 '16 at 20:06
87

Best example (IMHO) using timedatectl (in command-line/terminal):

$ timedatectl
      Local time: Thu 2014-07-24 19:51:23 IST
  Universal time: Thu 2014-07-24 14:21:23 UTC
        Timezone: Asia/Kolkata (IST, +0530)
     NTP enabled: no
NTP synchronized: no
 RTC in local TZ: no
      DST active: n/a

Visit the manpage for more settings and further information.

| improve this answer | |
9

Check out info date, and for example date +'%z'

| improve this answer | |
  • did not work! the output is like man date – usef_ksa Feb 22 '11 at 18:25
6

For me, date works fine:

Fri 22 Nov 2019 04:31:50 PM UTC

| improve this answer | |
2

For the time zone, you can use geolocation:

$ curl https://ipapi.co/timezone
America/Chicago

Or:

$ curl http://ip-api.com/line?fields=timezone
America/Chicago

http://wiki.archlinux.org/index.php/time#Time_zone

| improve this answer | |
1

If you need a formatted area and time zone, you can use:

$ grep `date +%Z` /etc/timezone 
  Etc/UTC
| improve this answer | |
  • This doesn't produce any output on my system. date +%Z returns CET, and file /etc/timezone contains Europe/Berlin. – Peter Mortensen Dec 28 '19 at 23:04
0

If you have PowerShell installed:

PS> Get-TimeZone

Id                         : Europe/Vilnius
DisplayName                : (UTC+02:00) Eastern European Standard Time
StandardName               : Eastern European Standard Time
DaylightName               : Eastern European Summer Time
BaseUtcOffset              : 02:00:00
SupportsDaylightSavingTime : True

I suspect this won't be popular answer in a Linux community, but I really like the verb-noun convention. It makes it easier for me to remember commands, and it will also work on all distributions with PowerShell installed :)

Documentation for the Get-TimeZone cmdlet

| improve this answer | |
  • 1
    Does PowerShell run on Linux? If so, at least add a reference on how to install it on Ubuntu. sudo snap install powershell is suggested, but references should be added as this is not a small commitment. Starting it results in (my emphasis): "error: This revision of snap "powershell" was published using classic confinement and thus may perform arbitrary system changes outside of the security sandbox that snaps are usually confined to, which may put your system at risk. If you understand and want to proceed repeat the command including --classic." – Peter Mortensen Dec 28 '19 at 23:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.