I have a shell script where I ask the system to return the year, 660days ago. On my Mac, I use this:
date -j -v-660d +"%Y"
If run today, that would return 2011.
I'm moving the script to an Ubuntu machine, and I receive an error, stating that the -j and -v options are invalid.
I've looked at the man page, looking for equivalent options, but haven't been able to find a solution.
Any help is appreciated.
Check the content of the spreadsheet you are trying to upload. Dates in your spreadsheet may be formatted in ways other than mmm-yyyy, such as dd-mmm-yyyy. Right-click these dates and click Format.
To format date in YYYY-MM-DD format, use the command date +%F or printf "%(%F)T\n" $EPOCHSECONDS . The %F option is an alias for %Y-%m-%d . This format is the ISO 8601 format.
Task: Display date in mm-dd-yy format Open a terminal and type the following date command: $ date +"%m-%d-%y" Sample outputs: 02-27-07.
Bash Date Format MM-DD-YYYY To format date in MM-DD-YYYY format, use the command date +%m-%d-%Y . Please observe the upper and lower case letters : %m for month, %d for day and %Y for year. %M would mean minutes.
This should work:
$ date -d '660 days ago' +%Y
2011
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With