date --date="STRING"
date --date="next Friday"
date --date="2 days ago"
date --date="yesterday"
date --date="yesterday" +"%format"
# Get yesterday's date in dd-mm-yy format
date --date="yesterday" +"%d-%m-%y"
date --date="yesterday" +"%m-%d-%y" # US date format
date --date="yesterday" +"%Y-%m-%d" # YYYY-mm-dd format
## store y'day date in a shell variable called yday and display it ##
yday=$(date --date="yesterday" +"%Y-%m-%d")
echo "$yday"
- You can use fortnight for 14 day.
- week for 7 days.
- hour for 60 minutes
- minute for 60 seconds
- second for one second
- You can also use this / now / today keywords to stress the meaning.
date --date='fortnight'
date --date='5 fortnight'
date --date='fortnight ago'
date --date='5 fortnight ago'
date --date='2 hour'
date --date='2 hour ago'
date --date='20 minute'
date --date='20 minute ago'
date --date='this Friday'
## OR ##
date --date='next Friday'
Set System Date & Time?
date --set='+30 minutes'
date --set='1 day ago'