Found it elsewhere:
1- echo `date "+%Y-%m-%d %H:%M:%S"` 2014-11-13 15:06:26 2- echo `date "+%y-%m-%d %H:%M:%S"` 14-11-13 15:06:51 Note: "+%y-%m-%d %H:%M:%S" case The given format FORMAT controls the output, and the interpretation sequence is as follows: %% % of a literal %a Abbreviated week name for the current locale (eg: day, for Sunday) %A The full week name of the current locale (eg Sunday) %b Abbreviation of the month name of the current locale (e.g. one for January) %B The full name of the month in the current locale (eg January) %c Date and time of the current locale (eg: Thu Mar 3 2005 23:05:25) %C Century; such as %Y, usually by omitting the last two digits of the current year (eg: 20) %d Date in month (eg: 01) %D Date in month; equals %m/%d/%y %e Monthly date, add spaces, equal to %_d %F full date format, equivalent to %Y-%m-%d %g Last two digits of year in ISO-8601 format (see %G) %G ISO-8601 format year (see %V), generally only used in combination with %V %h is equal to %b %H hours (00-23) %I hours (00-12) %c Date in year (001-366) at %k (0-23) %l(1-12) %m month (01-12) %M points (00-59) %n newline %N nanoseconds (000000000-999999999) %p "AM" or "PM" in the current locale, empty if unknown %P is like %p, but outputs lowercase letters %r The 12-hour clock time in the current locale (eg 11:11:04 PM) %R hour and minute of 24 hour time, equivalent to %H:%M %s The number of seconds since 1970-01-01 00:00:00 UTC %S seconds (00-60) %t output the tab character Tab %T time, equal to %H:%M:%S %u week, 1 for Monday %U Week of the year, with Sunday as the first day of the week (00-53) %V Week of the year in ISO-8601 format, with Monday as the first day of the week (01-53) %w The day of the week (0-6), 0 represents Monday %W Week of the year, with Monday as the first day of the week (00-53) %x Date description in the current locale (eg: 12/31/99) %X Time description in the current locale (eg 23:13:48) %y Last two digits of the year (00-99) %Y year %z +hhmm numeric time zone (for example, -0400) %:z +hh:mm Numeric time zone (for example, -04:00) %::z +hh:mm:ss Numeric time zone (for example, -04:00:00) %:::z Numeric time zone with necessary precision (eg -04, +05:30) %Z Alphabetical time zone abbreviation (for example, EDT)
From: http://www.cnblogs.com/galoishelley/p/4095022.html
Help information for the date command [root@localhost source]# date --help Usage: date [options]...[+format] 或:date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]] Display the current time in the given format, or set the system date. -d,--date=string Displays the time described by the specified string instead of the current time -f,--file=date file is similar to --date, read time description line by line from date file -r, --reference=file show the last modification time of the specified file -R, --rfc-2822 output date and time in RFC 2822 format For example: Monday 07 Aug 2006 12:34:56 -0600 --rfc-3339=TIMESPEC Output date and time in RFC 3339 format. TIMESPEC=`date',`seconds',或 `ns' Indicates the display precision of the date and time. Date and time units are separated by a single space: 2006-08-07 12:34:56-06:00 -s, --set=string set the specified string to separate the time -u, --utc, --universal output or set coordinated universal time --help display this help message and exit --version display version information and exit By default, the numeric area of the date is filled with 0s. The following optional tokens can follow "%": - (hyphen) does not fill the field _ (underscore) padded with spaces 0 (digital 0) padded with 0 ^ Use capital letters if possible # Use reverse case if possible An optional field width specification, which is a decimal number, is also allowed after any tokens. As an optional decorator declaration, it can be E, using the locale-related when possible Representation; or O, using the locale-associated number sign when possible.
From: http://blog.csdn.net/jk110333/article/details/8590746/