CentOS command-date
Summary:
The date command displays and sets the system date and time.
Command Format:
Date [OPTION]... [+ FORMAT]
Date [-u | -- utc | -- universal] [MMDDhhmm [[CC] YY] [. ss]
Parameters:
-D STRING: display the date described by STRING
-S STRING: set the date described by STRING
% Y (for example, 1970,2009)
% Y the last two digits of the year (1988 is 88)
% M month (01 .. 12)
% D the day of the month (01 .. 31)
% H hour (00 .. 23)
% I hour (01 .. 12)
% K hour (0 .. 23)
% L hour (1 .. 12)
% P displays AM or PM
% M (00 .. 59)
% S seconds (00 .. 59)
% R time (hh: mm: ss AM or PM), 12 hours
% T time (in 24-hour format) (hh: mm: ss)
% X display time format (% H: % M: % S)
% X display Date Format (mm/dd/yy)
% D Date (mm/dd/yy)
% S number of seconds that have elapsed since 00:00:00, January 1, January 1, 1970
This is commonly used, and the rest just needs to be directly checked by man...
Example:
1. There is a special time at noon today, 2009-08 07 12:34:56. You can use the following format to display the format 12/34/56/7/8/9. "-" Can ignore "0" in the first place ".
date +'%I/%M/%S/%-d/%-m/%-y'
2. Set the date to 20090807.
date -s 20090807
3. Set the time without changing the date
date -s 16:02:23
4. Set the date and time
date -s "20090807 16:02:23"
5. view the specific time from 100 days and 5 hours ago
date -d "-1 day 5 hour" +"%Y-%m-%d %H:%M:%S"
6. view the time after 100 minutes
date -d "+100 min" +"%Y-%m-%d %H:%M:%S"
7. Calculate the timestamp
date -d 20090528 +%s
8. Restore Timestamp
date -d "1970-01-01 1243440000 sec GMT" +"%F %T"
9. Update system time online using NTP protocol
ntpdate 210.72.145.44