Usage of the date command under Linux

Source: Internet
Author: User

Transfer from http://blog.chinaunix.net/uid-8223172-id-2511672.html

The use of date in Linux is more complex, but it also uses more, especially in the shell. Now summarize some of the usage that you often use.

1. Time Settings

# date-s 20080305--------> Set Date

# date-s 12:19:50-------> set time

2. Timestamp, time stamp is the number of seconds from January 1, 1970 0:0 to now.

Date +%s

Conversely: By the number of seconds to check the specific date

Date-d ' 1970-01-01 UTC 1204704624 seconds '

3. Display hours in 24-hour system

Date +%h

4. Display hours in 12-hour system

Date +%i

5. Display the month of the Year in decimal numbers (01-12)

Date +%m

6. Display minutes in decimal number (00-59)

Date +%m

7. Display the last two digits of the year (00-99)

Date +%y

8. Display the year in four digits in decimal

Date +%y

9. Display the date in YYYY-MM-DD mode

Date-i

Usage of the date command under 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.