How can I display the current time & date setting?

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

2

7 Answers

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
1

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.

2

For me, date works fine:

Fri 22 Nov 2019 04:31:50 PM UTC

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

1

For the time zone, you can use geolocation:

$ curl
America/Chicago

Or:

$ curl
America/Chicago

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

$ grep `date +%Z` /etc/timezone Etc/UTC
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

0

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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

You Might Also Like