Difference between revisions of "Date (command)"
Jump to navigation
Jump to search
↑ http://man7.org/linux/man-pages/man1/date.1.html
(19 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
+ | {{lowercase}} | ||
<code>date</code><ref>http://man7.org/linux/man-pages/man1/date.1.html</ref> command allows to print or set the system date and [[time]]. | <code>date</code><ref>http://man7.org/linux/man-pages/man1/date.1.html</ref> command allows to print or set the system date and [[time]]. | ||
Line 4: | Line 5: | ||
== Linux Basic Examples == | == Linux Basic Examples == | ||
− | $date -I or date --iso-8601 | + | $date -I or date [[--iso-8601]] |
2020-01-28 | 2020-01-28 | ||
+ | |||
+ | date '+%Y-%m-%d_%H%M' | ||
+ | 2023-10-11_1350 | ||
date --[[iso-8601]]=minutes | date --[[iso-8601]]=minutes | ||
Line 13: | Line 17: | ||
2014-03-19T16:51:16-0600 | 2014-03-19T16:51:16-0600 | ||
− | $date -- | + | $date [[--rfc-3339]]=date |
2020-01-28 | 2020-01-28 | ||
Line 55: | Line 59: | ||
</pre> | </pre> | ||
− | == | + | [[date -r]] |
− | + | ||
− | 2020-08- | + | == macOS Examples == |
+ | |||
+ | date +%F | ||
+ | 2021-07-18 | ||
+ | |||
+ | date +%F-%T | ||
+ | 2020-08-03-09:14:54 | ||
+ | |||
+ | date '+%Y/%m/%d %H:%M:%S' | ||
+ | 2021/07/18 16:32:26 | ||
+ | |||
+ | [[date +%s]] | ||
+ | 1655753367 | ||
+ | |||
+ | == [[Cisco IOS]] == | ||
+ | * <code>[[show clock]]</code> | ||
== Activities == | == Activities == | ||
# Read <code>date</code> man page: http://man7.org/linux/man-pages/man1/date.1.html | # Read <code>date</code> man page: http://man7.org/linux/man-pages/man1/date.1.html | ||
+ | # [[Prepend]] <code>date</code> output at the beginning of each line: <code>cat your_file.txt | [[while read]] i; do echo "$(date) $i"; done</code> | ||
+ | == Related == | ||
+ | * <code>[[datetime]]</code> https://docs.python.org/3/library/datetime.html | ||
+ | * <code>[[ts]]</code> (<code>[[apt install moreutils]]</code>) | ||
== See also == | == See also == | ||
+ | * {{date}} | ||
* {{logging}} | * {{logging}} | ||
* [[Cisco IOS]]: <code>[[show clock]]</code> | * [[Cisco IOS]]: <code>[[show clock]]</code> |
Latest revision as of 11:50, 11 October 2023
date
[1] command allows to print or set the system date and time.
Linux Basic Examples[edit]
$date -I or date --iso-8601 2020-01-28
date '+%Y-%m-%d_%H%M' 2023-10-11_1350
date --iso-8601=minutes 2020-07-07T08:32+04:00
date --iso-8601=seconds 2014-03-19T16:51:16-0600
$date --rfc-3339=date 2020-01-28
$ date -d now Wed Aug 18 16:47:31 EDT 2019 $ date -d today Wed Aug 18 16:47:32 EDT 2019
$ date -d yesterday Tue Aug 17 16:47:33 EDT 2019 $ date -d tomorrow Thu Aug 19 16:46:34 EDT 2019 $ date -d sunday Sun Aug 22 00:00:00 EDT 2019 $ date -d last-sunday Sun Aug 15 00:00:00 EDT 2019 Other valid date time strings include: last-week, next-week, last-month, next-month, last-year, and next-year. $ date +%b Aug $date "+%b %d" Aug 28 $ date +%B August $date "+%Y-%m-%d" 2020-10-11 $date "+%F_%H:%M-%Z" 2020-11-22_12:18-UTC $date --rfc-3339=date 2020-01-28
date -r
macOS Examples[edit]
date +%F 2021-07-18
date +%F-%T 2020-08-03-09:14:54
date '+%Y/%m/%d %H:%M:%S' 2021/07/18 16:32:26
date +%s 1655753367
Cisco IOS[edit]
Activities[edit]
- Read
date
man page: http://man7.org/linux/man-pages/man1/date.1.html - Prepend
date
output at the beginning of each line:cat your_file.txt | while read i; do echo "$(date) $i"; done
Related[edit]
See also[edit]
Advertising: