Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bash increment a date on Mac OS X

Tags:

bash

I am trying to increment date as follows (mac Catalina)

DATE=2019-01-01
NEXT_DATE=$(date +%m-%d-%Y -d "$DATE + 14 day")

but am getting date: illegal time format. How can I increment to the date?

like image 331
user13484252 Avatar asked May 08 '26 06:05

user13484252


1 Answers

In bash on Mac OS X, you can do like this:

date -j -v +14d -f "%Y-%m-%d" "2019-01-01" +%Y-%m-%d
like image 115
1218985 Avatar answered May 11 '26 00:05

1218985



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!