How to modify time date in Linux

Source: Internet
Author: User
Tags set time

Time to modify Linux can use the date directive

Date Modified:
The order of the time set to May 10, 2009 is as follows:
#date-S 05/10/2009

Modification Time:
The command to set the system time to 10:18 A.M. 0 seconds is as follows.
#date-S 10:18:00

To modify the time zone:
Locate the appropriate time zone file/usr/share/zoneinfo/asia/shanghai replace the current/etc/localtime.
Modify the contents of the/etc/sysconfig/clock file as:
Zone= "Asia/shanghai"

Sync BIOS Time:
Synchronize the BIOS clock and force the system time to be written to the CMOS command as follows:

The function of the date command is to display and set the system date and time.
Enter date to view the current system time.

Modify time requires date-Functional character modified content

The meanings of each of the options in the command are:
-D datestr,--date DATESTR displays the date described by datestr
-S Datestr,--set datestr Set the date of the DATESTR description
-U,--universal display or set Universal Time

Time Domain
%H hours (00). )
%I Hours (01.. )
%k hours (0). )
%l hours (1). )
%M points (00.. ()
%p Show am or PM
%r Time (Hh:mm:ss am or PM), 12 hours
%s from January 1, 1970 00:00:00 to the number of seconds currently experienced
%s seconds (00). ()
%T Time (24-hour system) (HH:MM:SS)
%x shows the format of Time (%h:%m:%s)
%Z time zone Date field
%a the abbreviation for the day of the week (Sun. Sat)
%A The full name of the week (Sunday. Saturday)
%b month abbreviation (Jan. DEC)
Full name of%B month (January. December)
%c Date and time (Mon Nov 8 14:12:46 CST 1999)
%d one months of the day (01). )
%d Date (MM/DD/YY)
%h and%b options are the same
%j The first day of the year (001. 366)
%m Month (01). )
%w Day of the week one (0 for Sunday)
%W The first few weeks of the year (00. 53, Monday for first day)
%x format for displaying dates (MM/DD/YY)
the last two digits of the%y year (1999 is the total)
%Y Year (ex: 1970,1996, etc.)

In particular, only the superuser can set the time with the date command, and the average user can only display the time with the date command.

Example 1: Displays the time in the specified format.
$ Date ' +this date ' is =>%x, time was now =>%x, thank! '
This date is =>11/12/99, and time is now =>17:53:01,thank!
Example 2: Displays the current time in a predetermined format.
# Date
Fri Nov 15:20:18 CST 1999
Example 3: Set time is 14:36 P.M..
# date-s 14:36:00
Fri Nov 14:15:00 CST 1999
Example 4: Set time is November 28, 1999.
# date-s 991128
Sun Nov 00:00:00 CST 1999

Example: Setting time Wei August 8, 2008 12:00
# date-s "2008-08-08 12:00:00"

After modifying, remember to enter: Clock-w
Write system time to CMOS

How to modify time date in Linux

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.