Home  >  Article  >  Operation and Maintenance  >  How to query the time zone in linux

How to query the time zone in linux

WBOY
WBOYOriginal
2022-03-11 15:58:0738201browse

Method: 1. Use the "date "%Z %z"" command to output the time zone in the form of characters and numbers; 2. Use the "timedatectl | grep "Time zone"" command to filter out the time zone information; 3. . Use the "cat /etc/timezone" command to view the file contents to output the time zone.

How to query the time zone in linux

#The operating environment of this tutorial: linux7.3 system, Dell G3 computer.

How to query the time zone in Linux

1. Use the date command to obtain time zone information

Use the following command to take a look See our current time zone:

date

Alternatively, you can use the command below. Among them, the %Z format can output the time zone in character form, and %z outputs the time zone in numeric form:

date +"%Z %z"

How to query the time zone in linux

Note: The date man page contains many output formats, you can Use them to replace the output of your date command:

man date

2. Use the timedatectl command to obtain time zone information

When you run it without any parameters, This command can output a system time overview as shown below, including the current time zone:

timedatectl

You can then provide a pipe in the command and use the grep command to filter out only the time zone as shown below Information:

timedatectl | grep "Time zone"

How to query the time zone in linux

3. Display the contents of the file /etc/timezone to obtain the time zone information

Use the cat tool to display the file / etc/timezone to check your time zone:

cat /etc/timezone

How to query the time zone in linux

Related recommendations: "Linux Video Tutorial"

The above is the detailed content of How to query the time zone in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn