Skip to main content
63 votes
Accepted

Can date format current time for GMT timezone?

You can use date -u (universal time) which is equivalent to GMT. Quoting date manual: ‘-u’ ‘--utc’ ‘--universal’ Use Universal Time by operating as if the ‘TZ’ environment variable ...
jimmij's user avatar
  • 47.5k
61 votes

Should I (still) use UTC for all my servers?

Is there any good reason to (still) use UTC as the system's time zone? Yes absolutely! Consider a major event that happens on 29 October 2023 at 02:30. Log messages are duly generated. (The relevance ...
Chris Davies's user avatar
56 votes
Accepted

Error message "date: invalid date '2016-10-16'"

The problem is the daylight saving time changed and forwarded 1 hour, on 16 October 2016 in your timezone: $ zdump -v America/Sao_Paulo | awk '/Oct 16/ && /2016/' America/Sao_Paulo Sun Oct ...
cuonglm's user avatar
  • 155k
51 votes
Accepted

Why is `TZ=Asia/Kolkata date --date="1/1/1906"` invalid?

According to the time zone database (which gives references to other sources), on January 1, 1906, the local time¹ in Kolkata changed from an offset of 5:21:10 (“Madras time”) to an offset of 5:30 (...
Stephen Kitt's user avatar
39 votes
Accepted

Should I (still) use UTC for all my servers?

I can really understand your log-reading pain, but I wouldn't want to discuss times in log files with my American and German colleagues during the ca 2 weeks a year where Daylights saving time has ...
Marcus Müller's user avatar
27 votes

How can I easily change my time-zone in Arch/Xfce?

It's as simple as typing in just one command: timedatectl set-timezone Zone/SubZone Where you replace Zone/SubZone with correct data. You can obtain list of all available timezones by typing: ...
Jakub's user avatar
  • 413
22 votes
Accepted

How to list timezones known to the system?

On Debian 9, your command gave me all of the timezones listed here: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones Additionally, systemd provides timedatectl list-timezones, which ...
Simon Fredsted's user avatar
22 votes

Should I (still) use UTC for all my servers?

Servers should always store UTC. Local time is a presentation layer issue that only humans need to see. If you, as a user, want to look at some timestamped data, then you probably want to see it in ...
Neil's user avatar
  • 329
21 votes

Can date format current time for GMT timezone?

Use the following command: TZ=GMT date The same format: TZ=GMT date +"%Y%m%d%H%M%S" 20171225194014
GAD3R's user avatar
  • 67.2k
20 votes
Accepted

How does `at` know there will be a time change?

at attempts to parse the date and time given and runs it through mktime() with "Daylight Saving Time" set to -1 (not available, auto-detect). at source code: tm1.tm_isdst = -1; t = mktime (&...
frostschutz's user avatar
  • 49.4k
20 votes
Accepted

How to disable DST changes for a timezone?

Part1: Update timeZone for the OS From 22-September 2022 onwards, Iran will abolish DST and observe standard time year-round. The first official package with these updates are came in "...
αғsнιη's user avatar
  • 41.4k
16 votes
Accepted

Different timestamps in SFTP "ls -l" vs. "ls -lh"

When listing a directory using SFTP protocol, the server provides both structured metadata of files (name, timestamp, size, etc) and textual listing of files. The OpenSSH sftp with -l switch prints ...
Martin Prikryl's user avatar
15 votes
Accepted

What's the difference between localtime and timezone files?

/etc/timezone is a text-based representation of what timezone you are in. This could be expressed as an offset from GMT/UTC, but more often it's the path under /usr/share/zoneinfo that points to the ...
Austin Hemmelgarn's user avatar
14 votes
Accepted

What is /etc/timezone used for?

GNU libc (and thus any non-embedded Linux), reads /etc/localtime to determine the system's time zone (the default timezone if not overridden by the TZ environment variable or by an application-...
Gilles 'SO- stop being evil''s user avatar
13 votes

Automatically set Linux timezone according to location

This is an old thread, but still relevant for kubuntu 1710 which doesn't change timezone automatically. I am using Chris Down's solution for tzupdate, but ensuring also that it gets triggered when the ...
Bharat Rajagopalan's user avatar
13 votes

How can I set a time zone on a Linux machine that has only very minimal cmds available?

If you don’t have timezone files, you can still specify the timezone by describing it in the TZ variable (see man tzset for details). The minimal form is the timezone name followed by the offset from ...
Stephen Kitt's user avatar
12 votes
Accepted

PST to PDT changes on April 1st instead of March 11 at 2:00am?

This sounds like your device is using the Pacific-New timezone, which is a proposed timezone that never became law in the US, and which specifies a switch to daylight-savings time on the first Sunday ...
Stephen Kitt's user avatar
11 votes
Accepted

Is my zoneinfo backwards or am I confused

There are actually two main ways to use the TZ variable. The older one is specified in the POSIX standards, and it can encode the timezone and the current year's Daylight Saving Time rules in the ...
telcoM's user avatar
  • 99.1k
11 votes

Should I (still) use UTC for all my servers?

You see the disadvantages of UTC (hard to translate into local time mentally). You don't see the advantages of UTC or rather the lack of problems: Having every server agree on the time is very, very ...
gnasher729's user avatar
9 votes
Accepted

How to correctly fake time?

This won’t explain the behaviour you’re seeing, but it should answer the question in the title. Instead of changing the system’s time, you could use a tool such as faketime and the TZ environment ...
Stephen Kitt's user avatar
8 votes
Accepted

Why is /etc/localtime a symbolic link?

You mention RHEL in your tags, so I assume this is what you're using. With RHEL 6 and earlier, when you upgrade the tzdata package then it triggers tzdata-update. This reads /etc/sysconfig/clock for ...
Stephen Harris's user avatar
8 votes

My local time is in the correct timezone, but isn't actually the real local time here

Just for completeness' sake, ensure that your default timezone is correct (which, since it already says Asia/Kolkata and IST in what you are seeing it likely is, this step being largely redundant): # ...
YourHelper's user avatar
8 votes
Accepted

For what do you need to change hardwareclock and how?

The articles you found are "wrong". By usual convention on Linux systems, you leave the hardware clock in a unified time zone (i.e., UTC), and the software converts the hardware time to a ...
Marcus Müller's user avatar
7 votes
Accepted

Why is timezone displayed as a number?

That's how it's now defined at the IANA official standard timezone database See ftp://ftp.iana.org/tz/tzdb-2017b/southamerica The name for the timezone in Winter time is -03. That corresponds to the ...
Stéphane Chazelas's user avatar
7 votes
Accepted

How to force debian to use UTC

The problem might be this link: lrwxrwxrwx 1 root root 23 Jun 4 13:09 /etc/localtime -> /usr/share/zoneinfo/UTC If this link was present before the cp /usr/share/zoneinfo/Europe/Berlin /etc/...
telcoM's user avatar
  • 99.1k
7 votes
Accepted

`timedatectl set-timezone` doesn't update `/etc/timezone`

timedatectl updates /etc/localtime, which is the documented way of setting the default timezone in most Linux-based environments (along with its override, the TZ environment variable, which is the ...
Stephen Kitt's user avatar
7 votes

How to list timezones known to the system?

If you want to retrieve the list on a system which does not use systemd here is an awk script which I have derived from the implementation of timedatectl list-timezones: awk '/^Z/ { print $2 }; /^L/ { ...
Christoph Freundl's user avatar
6 votes

How can I have `date` output the time from a different time zone?

Often you have timestamp in local timezone and you need to convert it to remote tz. It can be done with: TZ=America/Curacao date -d 'Tue Nov 28 00:07:05 MSK 2016' where: America/Curacao - remote ...
dimcha's user avatar
  • 61
6 votes
Accepted

Get current timezone as `Region/City`

In this comment by Stéphane Chazelas, he said: timedatectl is a systemd thing that queries timedated over dbus and timedated derives the name of the timezone (like Europe/London) by doing a ...
Tom Hale's user avatar
  • 30.9k
5 votes

How to get the timezone of a FTP server?

What I did before is creating an empty file and check the creation date. This usually gives a good estimation of time difference. I actually store the difference in seconds. Just in case I need it to ...
Edwin's user avatar
  • 51

Only top scored, non community-wiki answers of a minimum length are eligible