How to run the date command in Linux

displays the current date and time
date
displays the current date in the format YYYY-MM-DD
date +%F
displays the current time in the format HH:MM:SS
date +%T
displays the current timestamp (number of seconds since the Unix epoch)
date +%s
displays the date and time for the specified date
date -d "2022-12-05"
displays the date and time for the next Monday
date -d "next Monday"
displays the date and time for the last Monday
date -d "last Monday"
displays the date and time for the next day
date -d "+1 day"
displays the date and time for the previous day
date -d "-1 day"
displays the date and time for one week from now
date -d "+1 week"
displays the date and time for one week ago
date -d "-1 week"
displays the date and time for one month from now
date -d "+1 month"
displays the date and time for one month ago
date -d "-1 month"
displays the date and time for one year from now
date -d "+1 year"
displays the date and time for one year ago
date -d "-1 year"
displays the date and time for the specified date and time
date -d "2022-12-31 23:59:59"
displays the current date and time in the ISO-8601 format
date --iso-8601=seconds
displays the current date and time in the RFC 2822 format
date --rfc-2822
displays the current date and time in the UTC time zone
date --utc
displays the name of the day for the specified date
date --date="2022-12-31" +%A
displays the name of the month for the specified date
date --date="2022-12-31" +%B
displays the day of the week for the specified date (0-6, with 0 being Sunday)
date --date="2022-12-31" +%w
displays the week number of the year for the specified date
date --date="2022-12-31" +%W
displays the day of the year for the specified date (1-366)
date --date="2022-12-31" +%j
displays the year in the ISO-8601 calendar for the specified date
date --date="2022-12-31" +%G
displays the day of the week for the specified date (1-7, with 1 being Monday)
date --date="2022-12-31" +%u
displays the week number of the year for the specified date, starting on Sunday
date --date="2022-12-31" +%U
displays the week number of the year for the specified date, starting on Monday
date --date="2022-12-31" +%V
displays the year in the Gregorian calendar for the specified date
date --date="2022-12-31" +%Y
displays the year in the abbreviated format (e.g., 19, 20) for the specified date
date --date="2022-12-31" +%y
displays the month as a number (01-12) for the specified date
date --date="2022-12-31" +%m
displays the day of the month (01-31) for the specified date
date --date="2022-12-31" +%d
displays the date in the format MM/DD/YY for the specified date
date --date="2022-12-31" +%D
displays the date in the format YYYY-MM-DD for the specified date
date --date="2022-12-31" +%F
displays the time in the format HH:MM for the specified date
date --date="2022-12-31" +%R
displays the time in the format HH:MM:SS for the specified date
date --date="2022-12-31" +%T
displays the time in the default format for the specified date
date --date="2022-12-31" +%X
displays the time zone abbreviation for the specified date
date --date="2022-12-31" +%Z
displays the timestamp (number of seconds since the Unix epoch) for the specified date
date --date="2022-12-31" +%s
sets the system date and time to the specified date and time
date --set="2022-12-31 23:59:59"
sets the system date and time to one hour from now
date --set="+1 hour"
sets the system date and time to one hour ago
date --set="-1 hour"
sets the system date and time to one day from now
date --set="+1 day"
sets the system date and time to one day ago
date --set="-1 day"
sets the system date and time to one week from now
date --set="+1 week"
sets the system date and time to one week ago
date --set="-1 week"
sets the system date and time to one month from now
date --set="+1 month"
sets the system date and time to one month ago
date --set="-1 month"
sets the system date and time to one year from now
date --set="+1 year"
sets the system date and time to one year ago
date --set="-1 year"
prints the number of days until the specified date
date -d "2022-12-31" -j
prints the number of seconds since the beginning of the current day
date -d "today" -u +%s
converts a timestamp to a human-readable date and time
date -d "@1609378057" +"%Y-%m-%d %H:%M:%S"
prints the current time in a specific time zone
TZ="Asia/Tokyo" date -u +"%Y-%m-%d %H:%M:%S"
prints the current date and time in a specific format
date +"%A, %B %d, %Y %I:%M %p"
generates a 10-character hash of the current timestamp
date +"%s" | sha256sum | head -c 10
prints the date of the last Monday
date -d "last Monday" +"%Y-%m-%d"
prints the date of the next Monday
date -d "next Monday" +"%Y-%m-%d"
prints the name of the day of the week for tomorrow
date -d "tomorrow" +"%A"
prints the name of the day of the week for yesterday
date -d "yesterday" +"%A"
prints the name of the day of the week for two days ago
date -d "2 days ago" +"%A"
prints the month and year for one month from now
date -d "+1 month" +"%B %Y"
prints the month and year for one month ago
date -d "-1 month" +"%B %Y"
prints the year for two years from now
date -d "+2 years" +"%Y"
prints the year for two years ago
date -d "-2 years" +"%Y"
prints the time one hour from now
date -d "+1 hour" +"%R"
prints the time one hour ago
date -d "-1 hour" +"%R"
prints the date for one day from now
date -d "+1 day" +"%Y-%m-%d"
prints the date for one day ago
date -d "-1 day" +"%Y-%m-%d"
prints the date for one week from now
date -d "+1 week" +"%Y-%m-%d"
prints the date for three months from now
date -d "+3 months" +"%Y-%m-%d"
prints the date for one year from now
date -d "+1 year" +"%Y-%m-%d"
prints the year for one year ago
date -d "last year" +"%Y"
prints the year for one year from now
date -d "next year" +"%Y"
prints the time zone
date +"%Z"
prints the time zone offset from UTC
date +"%z"
prints the current timestamp with nanosecond precision
date +"%s.%N"
converts a timestamp to a human-readable date and time with nanosecond precision
date -d "@1609378057" +"%s.%N"
prints the timestamp for the next Sunday
date -d "next Sunday" +"%s"
prints the timestamp for the last Sunday
date -d "last Sunday" +"%s"
prints the timestamp for yesterday
date -d "yesterday" +"%s"
prints the timestamp for today
date -d "today" +"%s"
prints the timestamp for tomorrow
date -d "tomorrow" +"%s"
prints the timestamp for one week ago
date -d "last week" +"%s"
prints the timestamp for one week from now
date -d "next week" +"%s"
prints the timestamp for one month ago
date -d "last month" +"%s"
prints the timestamp for one month from now
date -d "next month" +"%s"
prints the timestamp for one year ago
date -d "last year" +"%s"
prints the timestamp for one year from now
date -d "next year" +"%s"
prints the timestamp for two hours from now
date -d "+2 hours" +"%s"
prints the timestamp for two hours ago
date -d "-2 hours" +"%s"
prints the timestamp for three days from now
date -d "+3 days" +"%s"
prints the timestamp for three days ago
date -d "-3 days" +"%s"
prints the timestamp for five months from now
date -d "+5 months" +"%s"
prints the timestamp for five months ago
date -d "-5 months" +"%s"
prints the timestamp for six years from now
date -d "+6 years" +"%s"
prints the timestamp for six years ago
date -d "-6 years" +"%s"
prints the timestamp for seven minutes from now
date -d "+7 minutes" +"%s"
prints the timestamp for seven minutes ago
date -d "-7 minutes" +"%s"
prints the timestamp for eight seconds from now
date -d "+8 seconds" +"%s"