The date command in Linux

Source: Internet
Author: User

The data command displays and changes the system time

Date Syntax and parameters:

Date [OPTION] ... [+format]

Date [-u|--utc|--universal] [MMDDHHMM[[CC]YY][.SS]]

Parameters Words Description
-S Set Setting the system time
-D Date Specify display time

Time Format:

Time format Words Example Format description
%F Year-month-day 2014-11-12 Year-month-day
%T Hour-minute-second 14:28:30 Hours-minutes-seconds
%Y Year 2014 Years
%y Year 14 Year (the last two digits of the year)
%m Month 11 Month
%d Day 12 Day
%H Hour 14 When
%M Minute 28 Score of
%s Second 30 Seconds
%s Second
From 1970-01-01 onwards
%w Week 2 Week

Date Example:

[[Email protected] ~]$ Date

Wednesday, November 12, 2014 14:31:29 CST

Description: Displays the current system time


[[Email protected] ~]# date- s 2012-11-13

November 13, 2012 Tuesday 00:00:00 CST

Description: Set the system time


[Email protected] ~]# Hwclock- w

[Email protected] ~]# Hwclock

January 09, 1990 Tuesday 00:00 15 sec -0.924544 seconds

Description: Hwclock-w is synchronizing the time to the BIOS


[Email protected] ~]# ntpdate time.windows.com

14:52:17 ntpdate[2298]: Step time server 64.4.10.33 offset 783960574.614420 sec

[[Email protected] ~]# Date

Wednesday, November 12, 2014 14:52:23 CST

[[email protected] ~]# hwclock-w sync time to BIOS

Description: Resynchronize the time to the current time


[Email protected] ~]# date +%f-%t

2014-11-12-14:54:39

Description: Display date year-month-day time-minute-second


[Email protected] ~]# date +%d

11/12/14

[Email protected] ~]# date +%w

45

Description: 45 for the 45th week of this year


[[Email protected] ~]# date +%f-d ' 3 day '

2014-11-15

Description: Three days after the time

[[Email protected] ~]# Date +%f-d '-3 day '

2014-11-09

Description: Three days before the time



[[Email protected] ~]# Date +%f-%t-d '-3 hour '

2014-11-12-12:01:03

Description: Three hours before the time

[[Email protected] ~]# Date +%f-%t-d ' 3 hour '

2014-11-12-18:01:07

Description: Three hours after the time

Note: For accurate time, the preceding output must be complete +%f-%t



This article is from the Linux Operations sharing blog, so be sure to keep this source http://liangey.blog.51cto.com/9097868/1575711

The date command in Linux

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: info-contact@alibabacloud.com 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.