Use one of the below methods to get the current date in “YYYY-MM-DD” format.

Using date command – To print the results in YYYY-MM-DD format, you can use %Y-%m-%d or %F options with date command. Here the %F option is an alias for %Y-%m-%d. date +%F #Output: 2022-07-25 date +%Y-%m-%d #Output: 2022-07-2512date +%F         #Output: 2022-07-25date +%Y-%m-%d   #Output: 2022-07-25 Using printf command – Rather than using the date command, the print command also provides a built-in date formatted in bash (>=4.2). printf ‘%(%Y-%m-%d)T\n'1printf ‘%(%Y-%m-%d)T\n’

The above methods print the results on standard output. You can also store the results in a variable like: