Shell Date Command Collation

Source: Internet
Author: User
Tags local time month name

Recently found that the date command is especially useful (not in Mac)

1. Get today's date

[Email protected] ~]# date +%y%m%d20141123

2. Get the date of a day

" 2014-11-12 " +%y%m%D20141112

This seems like crap, but it's okay, keep looking.

3. Get a day of the week

" 2014-11-23 " +%w0

4, get a day two months before the week

" -2 month 2014-11-23 " +%w2

5. Similarly:

" -1 week  "+%y%m%--date="-24 hour"

6. Format:

%a weekday abbreviation for the current field (Sun.. Sat)%a The current week of the field is fully written (Sunday. Saturday)%b The month abbreviation for the current field (Jan. DEC)%B The full month name of the current field (January). December)  %d two-bit days ( on.. to)%d Short time Format (mm/dd/yy)%e Short Format days (1.. to)%F file Time format same as%y-%m-%D%h Same as%b%H 24-Hour Hour (xx.. at)%I 12-Hour Hour ( on.. A)%j the first day of the year (001..366)%k short Format 24-hour hour (0.. at)  %m Double-digit month ( on.. A)%M double-digit minutes (xx.. -)  %r 12-hour time indication (time: minute: Second, double) A-Hour (hh:mm:ss [ap]m)%R 24-hour time representation (hours: minute, double) --Hour (hh:mm)%s from base time1970- on- on xx:xx:xxThe number of seconds to the current moment (a GNU extension)  %T 24-hour time representation (HH:MM:SS)%u number expressed in weeks (starting from Monday1-7)  %x Local date format (mm/dd/yy)%x local time format (%h:%m:%S)%y Two-bit year (xx.. About)%Y Year (1970...)

Shell Date Command Collation

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.