The easiest way to get a date in YYYY-MM-DD is follows:
The parameter “I” tells the date command, the ISO date format is required.
Of course, you can also use your own definition. %Y means year, %m means month, and %d means day:
Output: 2016-06-07, the same.
If you want to display also hours:minutes:second, let's do:
You fill the variable date as follows:
Here are some examples of format control:
Was this information helpful to you? You have the power to keep it alive.
Each donated € will be spent on running and expanding this page about UNIX Shell.
We prepared for you video course Marian's BASH Video Training: Mastering Unix Shell, if you would like to get much more information.
Thank you. Marian Knezek