Raspberry Pi_Eng_10.10.1 “date” Command- Confirm & Change Time Information


Published Book on Amazon


All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 1
All of IOT Starting with the Latest Raspberry Pi from Beginner to Advanced – Volume 2


출판된 한글판 도서


최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (상)
최신 라즈베리파이(Raspberry Pi)로 시작하는 사물인터넷(IOT)의 모든 것 – 초보에서 고급까지 (하)


Original Book Contents


10.10    Commands Related to System Information

 

10.10.1   "date" Command- Confirm & Change Time Information

 

The time zone set in the current system can be changed using "raspi-config" command. For details, refer to the description of [9.2 How to Configure the System].

If the system is connected to the Internet, it will connect to the time server on the network and set the time automatically. This configuration is handled automatically each time the system boots. Therefore, even if you change the time manually, the next time you boot, it will be reset to the time of time server.

On Linux, use the "date" command to directly query or adjust the system date and time.

 

[Command Format]

date  [OPTION]... [+FORMAT]

date  [option]   [MMDDhhmm[[CC]YY][.ss]]

 

[Command Overview]

   This can view or change the current date and time of the system.

   User privilege          -- Normal user.

                                -- Super user privilege is necessary for setting

 

[Detail Description]

   Date format is as follows.

    MM      -- Month

    DD       -- Day

    hh       -- Hour

    mm      -- Minute

    ss        -- Second

    CCYY     -- Year

   If no special argument is specified, the current information is displayed.

 

 

[Main Option]

-u, --utc, --universal

print or set Coordinated Universal Time

-d, --date=STRING

display time described by STRING, not 'now'

-s, --set=STRING

set time described by STRING

 

[Used Example]

First, let's check the current date and time information. Execute the command as follows.

 

pi@raspberrypi ~ $ date

Sat Apr 25 23:10:00 KST 2015

 

The current time information is displayed. This time is indicated on the standard time of Korea Seoul (KST). It displays Saturday, April 25, 2015, and the time is 23:00:25.

Now, let's check the current time information on the standard time of Universal Time Coordinate (UTC) rather than KST. To do this, use "-u" option to run the command.

 

pi@raspberrypi ~ $ date u

Sat Apr 25 02:10:00 UTC 2015

 

The current system time is converted to UTC standard and displayed. It is Saturday, April 25, 2015, and the time is 02:10:00

Now let's change the current time information. Changing the time requires super user privilege, so we used the "sudo" command to specify the time information we want to change.

 

pi@raspberrypi ~ $ sudo date 042411302015

Fri Apr 24 11:30:00 KST 2015

 

We changed the current time to 11:30:00 on April 24, 2015. After the operation is completed, the changed information is displayed again below. It can be seen that the changing work was based on Korea Seoul (KST) standard.