About the linux system time

    Stating: / etc / localtime determines your time zone, if it does not, the system is set to utc (0 time zone) time.

    These configuration files in / usr / shara / zoneinfo in, for example GMT / usr / share / zoneinfo / Asia / Shanghai, copy this file to / etc / localtime can set the correct time zone of their own.

   The second point is utc time timestamp, time and gettimeofday is obtained. Want local time, use the localtime function transformation. date command to check the time, people are identified (UTC or CST).

Do not underestimate the time this stuff, when you and future network or dealing with audio and video, time is very important.

       Embedded in time, if the time zone change, a lot of trouble. You can use export TZ = CST-08: 00 to modify the local time, or normal utc time when using time and gettimeofday.

 -------------------------------------------------- ------------------------nonsense------------------------- -------------------------------------------------- -------------

    I installed ubuntu after a find at the wrong time, how to set wrong. I looked at the use of date

DATE #
Mon 24-Jun 23:08:37 EDT 2019, I am Beijing time is 11: 09, EDT -04: 00 Eastern Daylight is, corresponds New York time. So how do we get to the time zone it?

    Do not worry, the first play following command tzselect

xx@ubuntu:etc$ tzselect 
Please identify a location so that time zone rules can be set correctly.
Please select a continent, ocean, "coord", or "TZ".
 1) Africa
 2) Americas
 3) Antarctica
 4) Asia
 5) Atlantic Ocean
 6) Australia
 7) Europe
 8) Indian Ocean
 9) Pacific Ocean
10) coord - I want to use geographical coordinates.
11) TZ - I want to specify the time zone using the Posix TZ format.
#?  4

Select 4 (Asian)

Please select a country whose clocks agree with yours.
 1) Afghanistan          18) Israel            35) Palestine
 2) Armenia          19) Japan            36) Philippines
 3) Azerbaijan          20) Jordan            37) Qatar
 4) Bahrain          21) Kazakhstan        38) Russia
 5) Bangladesh          22) Korea (North)        39) Saudi Arabia
 6) Bhutan          23) Korea (South)        40) Singapore
 7) Brunei          24) Kuwait            41) Sri Lanka
 8) Cambodia          25) Kyrgyzstan        42) Syria
 9) China          26) Laos            43) Taiwan
10) Cyprus          27) Lebanon            44) Tajikistan
11) East Timor          28) Macau            45) Thailand
12) Georgia          29) Malaysia            46) Turkmenistan
13) Hong Kong          30) Mongolia            47) United Arab Emirates
14) India          31) Myanmar (Burma)        48) Uzbekistan
15) Indonesia          32) Nepal            49) Vietnam
16) Iran          33) Oman            50) Yemen
17) Iraq          34) Pakistan
#? 9

Now 9 (China)

Please select one of the following time zone regions.
1) Beijing Time
2) Xinjiang Time

#? 1
Select 1 GMT

The following information has been given:

    China
    Beijing Time

TZ = THEREFORE 'Asia / on Shanghai' by Will BE Used.
Local Time IS now: Tue Jun 25 11:15:26 CST 2019.
Universal Time IS now: Tue Jun 25 03:15:26 UTC 2019.
Is is at The Information above the OK?
1) Yes
2) No
# Yes?
the above information is not what you want ah, we look, 11:16 right on, CST eight districts of the east, so enter yes. Then on ok

xx@ubuntu:etc$ date
Mon Jun 24 23:17:49 EDT 2019

Find date about right or wrong. The above is just to tell you that you looked to the Asia / Shanghai here to get the configuration file / etc / localtime, so it worked

sudo cp  /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime 

@ Ubuntu YP: etc $ DATE
Tue Jun 25 11:22:17 CST 2019
viewing time once again when he became the Beijing time.

xx@ubuntu:etc$ sudo mv localtime  looooocaltime
xx@ubuntu:etc$ date
Tue Jun 25 03:30:08 UTC 2019

This becomes a practice time utc (0 time zones) of the
 

[root@Ingenic-uc1_1:test]# ./mips-getutc 
time:28
1/1/1970
0:0:28
gettimeofday tzone.tz_minuteswest:0
gettimeofday tzone.tz_dsttime:0
gettimeofday ret=0
gettimeofday scond= 28 
gettimeofday uscond= 608883 
[root@Ingenic-uc1_1:test]# export TZ=CST-08:00
[root@Ingenic-uc1_1:test]# date
Thu Jan  1 08:02:30 CST 1970
[root@Ingenic-uc1_1:test]# ./mips-getutc 
time:167
1/1/1970
8:2:47     //说明local time变了
gettimeofday tzone.tz_minuteswest:0
gettimeofday tzone.tz_dsttime:0
gettimeofday ret=0
gettimeofday scond= 167    //说明utc没变
gettimeofday uscond= 278584

------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Guess you like

Origin blog.csdn.net/qq_16810885/article/details/93602139