View or change dates.
Syntax date [options] ... [+Format] data [-u|--utc|--universal] [MMDDhhmm[[CC]AA][.ss]]
"date" with no arguments prints the current time and date in the format％Cinstructions (described below).
If given an argument starting with a+,dataprints the current time and date (or by- dataoptions, see below) in the format defined by this parameter, with thework scheduleFunction.
In addition to directives beginning with%, the characters in the format string will be printed as-is. These instructions are described below.
Options: -d, --data=KedaThe display time is described asKeda, instead of "now", can be in almost any common format. It can contain month name, time zone, 'am' and 'pm', 'yesterday', 'before', 'next', etc.date fileLike --date once per linedate fileseleniumdate fileFor "-", use standard input. This is useful when you have a lot of data to process, as the overhead of launching the "data" executable is usually considerable. -I, --iso-8601[=time specification] to make aISO 8601Compatible data/time strings, '%Y-%m-%d'.time specification="date" (or its absence) means date only, and "hour", "minute" or "second" means a datetime with the specified precision. If any time terms are displayed, include the time zone using the "%z" format. If "--utc" is also specified, use "%Z" instead of "%z". -r, --reference=documentshow last modified timedocument-R, --rfc-822 Example RFC-822 compliant date string output: Mon Nov 19, 2012 12:44:56 -0600 Deprecated in favor of --rfc-email --rfc-3339=FMMTOutput date/time in RFC 3339 format.FMMT='date', 'seconds', or 'ns' represents a date and time with the specified precision. Example: 8/14/2006 02:34:56-06:00 -R, --rfc-email Output date and time in RFC 5322 format. Example: Monday, August 14, 2006 02:34:56 -0600 -s , --set=KedaSet the time for the descriptionKeda(see -d above) -u, --utc, --universal print or set UTC --help show this help and exit --version print version information and exit
%%a Literal% % Abbreviated weekday name for location (Sunday..Saturday) % Full weekday name for location, variable length (Sunday..Saturday) %b Abbreviated name for month for location (January..December ) %B position full month name, variable length (January..December) %c position date and time (e.g. Thursday, March 3, 2005, 23:05:25) %C century; Same as %Y, but omit last two digits (eg, 20) %d day of month (01..31) %D date (mm/dd/yy) equals %m/%d/%y % e date month, fill in the blank (1..31); equals %_d %F complete date; is %+4Y-%m-%d %g ISO week number Last two digits of year (see %G) %G ISO week Number of years (see %V); normally only useful if %V %h equals %b, position month abbreviated name (Jan..Dec) %H time: 24 hours (00..23) %I time: 12 hours ( 01..12) % j day of the year (001..366) %k time, space filled (0..23); equals %_H %l time, space filled (1..12); Equal to %_I %m month (01..12) %M minute (00..59) %n newline %N nanosecond (000000000..999999999) %p local equivalent of AM or PM; blank if unknown %P is %p but lowercase %q quarter of year (1..4) %r local 12-hour time (eg 11:11:04s) %R 24-hour hour and minute; equals %H:%M % s The number of seconds (GNU extension) since 1970-01-01 00:00:00 (Unix days) Usually used to generate website URLs. Defined by the local time system call. It is not changed by the "--date" option. %S seconds (00..60) %t horizontal tab %T hour, 24 hours (hh:mm:ss) equals %H:%M:%S %u day of the week (1..7) ;1 is Monday %U week of the year, Sunday is the first day of the week (00..53) %V ISO week number, Monday is the first day of the week (01..53) if the week If the new year contains January 1 and has four or more days, then week 1 is considered; otherwise, week 53 of the previous year and the next week is week 1. similar toISO 8601(But it's not 100% compatible because it's not locale-aware.) %w day of the week (0..6); 0 means Sunday %W week of the year with Monday being the first day of the week (00. .53) %x location date representation (mm/dd/yy) %X location time representation (%H: %M:%S) %y last two digits of year (00..99) %Y year (1970. ..) %z RFC-822 style numeric time zone (-0500) (non-standard extension) +hhmm time zone numeric time (eg, -0400) This value reflectscurrentTime zone. It is not changed by the --date option. %:z +hh:mm Numeric time zone (eg -04:00) %::z +hh:mm:ss Numeric time zone (eg -04:00:00) %:::z Time zone numeric with : required with Precision (eg -04, +05:30) %Z Time offset from UTC (-07) Usually consists of time zone +summer timeIt is not changed by the --date option.
Numeric fields are filled with zeros by default. GNU Date recognizes modifiers between%and a numeric command.
-(hyphen) Do not fill in this field; useful if produced for human consumption.
_(underscore) pad the field with spaces; useful if you need a fixed number of characters in the output, but zeros are too distracting.
0(zero) block with zero
+Pad with zeros and add '+' before future years with more than 4 digits
^use capital letters if possible
#Use the opposite case if possible
Any flags are followed by an optional field width, such as a decimal number; followed by an optional modifier, E to use the locale's alternate representation, if available, or O to use the locale's alternate number notation, if available ).
oxygen-e_is a GNU extension. Here is an example illustrating the difference:
date+%d/%m -d "February 1st" => 02/01 date+%-d/%-m -d "February 1st" => 1/2 date+%_d/%_m - d "February 1st" => 1/2
Here's the code for the same format in a category:
Date: %D Date in mm/dd/yy format (6/24/13) %x Date in default locale format (9/24/13 for US English) Year: %C Century (20 to 2015) %Y year in 4-digit format (2015) %y year in 2-digit format (14) %G equals 'Y' %g equals 'y' month: %b month name - abbreviation (January) %B month name month - full (January) %h same as 'b' %m month number (09) week: %U week number of year with Sunday as first day of week (00..53) %V ISO week Number, Monday is the first day of the week First day of the week (01..53) %W Week number of the year, Monday is the first day of the week (00..53) Day: %a week of the week %A Day of the week - short name (Mon) %A Day of the week - full name (Monday) %u day of the week - number (Monday = 1) %d day of the month - 2 digits (05) %e month day of the year - number preceded by a space (5) % j day of the year - (1-366) %u day of the week (1..7); 1 is Monday %w with "u " same time: %p AM or PM %r time in 12 hour format (09:15:36 AM) %R time in 24 hour format - no seconds (17:45) % time T in 24 hour format (17:45 :52) %X equals 'T' %Z time offset from UTC (-07) usually consists of time zone +summer timeTime: %H time in 24 hour format (17) %I time in 12 hour format (05) %k equals 'H' %l equals 'I' (uppercase I = lowercase L) minutes and seconds: %M minutes(35 ) %S seconds(05) %s seconds elapsed since January 1, 1970 00:00:00 UTC (Unix time)
If the parameter given is not in the+,dataSets the system clock to the time and date specified by this parameter (described below). You must have appropriate permissions to set the system clock. oxygen- datae- DefinitionOptions cannot be used with such parameters. oxygen- commonThis option can be used with this parameter to indicate that the specified time and date are relative to Coordinated Universal Time rather than the local time zone.
This parameter must consist entirely of numbers, with the following meanings:
MM month DD day of month HH hour MM minute CC first two digits of year (optional) YY last two digits of year (optional) SS seconds (optional) The '--set' option also sets the system clock; please See an example below.
Print the day before yesterday's date:
$ data --data='2 days ago'
Rename files with current date and time
$ mv $HOME/demo_file $STAMPME
Display time for US West Coast (use tzselect(1) to find TZ)
$TZ='United States/Los Angeles'
Displays the local date/time for next Friday at 9:00 AM on the West Coast of the United States
$ date --date='TZ="America/Los_Angeles" next Friday at 09:00 AM'
Print the date three months and one day from now:
$ data --data='3 months 1 day'
Print the date of Christmas for the current year:
$ date --date='December 25th' +%j
Print the full name of the current month and the day of the month:
$data '+%B %d'
Note that "%d" expands to a zero-padded two-digit field, for example:
$ data -d 1maio '+%B %d'will print "01 May".
Prints the date without leading zeros with single-digit days in the month. You can suppress padding entirely by using the modifier (GNU extension) "-".
$ data-d=1maio '+%B %-d'
When setting the system clock, print the current date and time in the format required by many non-GNU versions of 'date':
Set system date and time
$data --set="29/06/2012 11h59"
To advance the system clock by two minutes:
$ data --set='+2 minutes'
prints the date asISO 8601Supported date/time strings:
To convert a date string to seconds since epoch 1970-01-01 00:00:00 GMT (Unix time), use the '--date' option in the format '%s'. This is useful for sorting and/or graphing and/or comparing data by date. The following command outputs the number of seconds elapsed since the epoch, but in a time zone five hours past (Cambridge, Massachusetts), so a total of five hours and one second elapsed since the epoch:
$ data --date='2000-01-01 00:00:01 UTC +5 hours' +%s
suppose you haveNoThe time zone information specified in the example above. So the date will use your computer's time zone idea (andsummer time) when interpreting a string. If you were in Greenwich, UK, you would get the following result:
# will use local timezone
$ data --data='2000-01-01 00:00:01' +%s
Seconds since the 1970s are useful when sorting or graphing outdated data. But to convert the seconds back to a more readable date, use a command like this:
$ data -d '1970-01-01 946684800 seg' + "%Y-%m-%d %T %z"
Jan 1, 2000 00:00:00 +0000
"Carpe Diem - Seize the Day" ~ Horace
Related Linux commands
Carl- View calendar.
timed task- Schedule commands to run at a later time.
speed- Measure program resource usage.
Second-rate- User and system time.
tap- Change file timestamps.
Standard Date and Time Notation-AAAA-MM-DD
unix timestamp. com- Online converter.
Equivalent Windows command:data- view or set date +speed- View or set system time.
Copyright © 1999-2023SS64.com
some rights reserved