Bash: Calculate Date in Ubuntu and Mac OS

Display current date
date +'%Y-%m-%d %H:%M'
2015-08-07 17:06

Add 3 mins, 5 days, 2 months, 4 years to current date (Mac OS)
date -v +3M -v +5d -v +2m -v +4y +'%Y-%m-%d %H:%M'
2019-10-12 17:09

Add 3 mins, 5 days, 2 months, 4 years to current date (Ubuntu)
date -d "3 minutes 5 days 2 months 4 years" +'%Y-%m-%d %H:%M'
2019-10-12 17:09

Comments