Linux Command--date Command &cal command

Source: Internet
Author: User

The date command is used to display the time, and the CAL command is used to display the calendar.

Some of the common formats for the date command are

%H hours (expressed in 00-23). %I Hours (expressed in 01-12). %K hours (expressed in 0-23). %l hours (expressed in 0-12). %M minutes (expressed in 00-59). %P am or PM. %r time (including hours, minutes and seconds, hour is expressed as 12 hours am/pm). Total number of seconds in%s. The starting time is 1970-01-01 00:00:00 UTC. %s seconds (as represented by local idioms). %T time (minutes and seconds, hours are expressed in 24-hour system). %x time (expressed in local idiomatic notation). %Z downtown. %a abbreviation of the week. The full name of the%A week. Abbreviation for%b month English name. The full English name of the%B month. %c date and time. Entering only the date instruction will also show the same result. %d date (expressed as 01-31). %d Date (including month date). %j the first day of the year. %m month (expressed as 01-12). %u the number of weeks in the year. %w the number of days of the week, 0 for Sunday, 1 for Monday, once analogy. %x date (expressed in local idiomatic notation). %y year (expressed in 00-99). %Y year (expressed in four digits). %n inserts a new line when it is displayed. %t when displayed, Insert tab. MM month (necessary) DD date (necessary) HH hours (necessary) mm minutes (necessary) SS seconds (optional)

Use Case 1 Show time

zimingdemacbook-air:~ ziming$ date2015 October 7 Wednesday 18:08 10 seconds cstzimingdemacbook-air:~ ziming$ Date ' +%c ' 310/7 18:08:43 20 15zimingdemacbook-air:~ ziming$ Date ' +%d ' 10/07/15zimingdemacbook-air:~ ziming$ date ' +%x ' 2015/10/ 07zimingdemacbook-air:~ ziming$ Date ' +%t ' 18:10:08zimingdemacbook-air:~ ziming$ date ' +%x ' 18:10 13 sec zimingdemacbook-air:~ ziming$

Use case 2 to display time with%n line wrapping

Date ' +%t%n%d '


Cal commands are used to display calendars

Use Case 1 Displays the November 2015 calendar, if the-m parameter is the first day of Sunday

Cal 11 20,151 Month 2015 Day 1,234,561 2 3 4 5 6 7 8 9 10 11 12 13 1415 16 17 18 19 20 2122 23 24 25 26 27 2829 30

Use case 2 shows the day of the week from January 1

Cal-j October 2015 123,456,274 275 276277 278 279 280 281 282 283284 285 286 287 288 289 29 0291 292 293 294 295 296 297298 299 300 301 302 303 304

Reference Documentation:

Http://www.cnblogs.com/peida/archive/2012/12/13/2815687.html

Http://www.cnblogs.com/peida/archive/2012/12/14/2817473.html


Linux Command--date Command &cal command

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.